file_path
stringlengths
20
207
content
stringlengths
5
3.85M
size
int64
5
3.85M
lang
stringclasses
9 values
avg_line_length
float64
1.33
100
max_line_length
int64
4
993
alphanum_fraction
float64
0.26
0.93
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRExampleCabinetPPO.yaml
params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRCabinet,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.01 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 5e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 100000000 max_epochs: ${resolve_default:1500,${....max_iterations}} save_best_after: 200 save_frequency: 100 print_stats: True grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 16 minibatch_size: 16384 mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,630
YAML
21.971831
101
0.597546
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRExampleReachPPO.yaml
name: HSRExampleReachPPO params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRExampleReach,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.1 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 3e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 20000 max_epochs: ${resolve_default:250,${....max_iterations}} save_best_after: 50 save_frequency: 100 grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 128 minibatch_size: 131072 mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,634
YAML
21.708333
101
0.600979
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRResidualLiftPPO.yaml
name: HSRResidualLiftPPO params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRResidualLift,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.1 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 3e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 20000 max_epochs: ${resolve_default:250,${....max_iterations}} save_best_after: 50 save_frequency: 100 grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 135 minibatch_size: 138240 # horizon_length * num_envs mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,662
YAML
22.097222
101
0.602888
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRExamplePlacePPO.yaml
name: HSRExamplePlacePPO params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRExamplePlace,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.1 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 3e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 20000 max_epochs: ${resolve_default:250,${....max_iterations}} save_best_after: 50 save_frequency: 100 grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 128 minibatch_size: 131072 # horizon_length * num_envs mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,662
YAML
22.097222
101
0.602888
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRExamplePickPPO.yaml
name: HSRExamplePickPPO params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRExamplePick,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.1 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 3e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 20000 max_epochs: ${resolve_default:250,${....max_iterations}} save_best_after: 50 save_frequency: 100 grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 128 minibatch_size: 131072 mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,632
YAML
21.680555
101
0.60049
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRResidualStackPPO.yaml
name: HSRResidualStackPPO params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRResidualStack,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.1 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 3e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 20000 max_epochs: ${resolve_default:250,${....max_iterations}} save_best_after: 50 save_frequency: 100 grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 256 minibatch_size: 1048576 # horizon_length * num_envs mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,665
YAML
22.138889
101
0.603604
makolon/hsr_isaac_tamp/hsr_rl/cfg/train/HSRExampleInsertPPO.yaml
name: HSRExampleInsertPPO params: seed: ${...seed} algo: name: a2c_continuous model: name: continuous_a2c_logstd network: name: actor_critic separate: False space: continuous: mu_activation: None sigma_activation: None mu_init: name: default sigma_init: name: const_initializer val: 0 fixed_sigma: True mlp: units: [256, 128, 64] activation: elu d2rl: False initializer: name: default regularizer: name: None load_checkpoint: ${if:${...checkpoint},True,False} # flag which sets whether to load the checkpoint load_path: ${...checkpoint} # path to the checkpoint to load config: name: ${resolve_default:HSRExampleInsert,${....experiment}} full_experiment_name: ${.name} env_name: rlgpu device: ${....rl_device} device_name: ${....rl_device} multi_gpu: ${....multi_gpu} ppo: True mixed_precision: False normalize_input: True normalize_value: True num_actors: ${....task.env.numEnvs} reward_shaper: scale_value: 0.1 normalize_advantage: True gamma: 0.99 tau: 0.95 learning_rate: 3e-4 lr_schedule: adaptive kl_threshold: 0.008 score_to_win: 20000 max_epochs: ${resolve_default:250,${....max_iterations}} save_best_after: 50 save_frequency: 100 grad_norm: 1.0 entropy_coef: 0.0 truncate_grads: True e_clip: 0.2 horizon_length: 128 minibatch_size: 131072 mini_epochs: 8 critic_coef: 4 clip_value: True seq_len: 4 bounds_loss_coef: 0.0001
1,636
YAML
21.736111
101
0.601467
makolon/hsr_isaac_tamp/hsr_rl/scripts/train_rlgames_mt.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.utils.hydra_cfg.hydra_utils import * from hsr_rl.utils.hydra_cfg.reformat import omegaconf_to_dict, print_dict from hsr_rl.utils.rlgames.rlgames_utils import RLGPUAlgoObserver, RLGPUEnv from hsr_rl.utils.task_utils import initialize_task from hsr_rl.utils.config_utils.path_utils import retrieve_checkpoint_path from hsr_rl.envs.isaac_env_rlgames_mt import IsaacEnvRlgamesMT import hydra from omegaconf import DictConfig from rl_games.common import env_configurations, vecenv from rl_games.torch_runner import Runner import copy import datetime import os import threading import queue from omni.isaac.gym.vec_env.vec_env_mt import TrainerMT class RLGTrainer(): def __init__(self, cfg, cfg_dict): self.cfg = cfg self.cfg_dict = cfg_dict def launch_rlg_hydra(self, env): # `create_rlgpu_env` is environment construction function which is passed to RL Games and called internally. # We use the helper function here to specify the environment config. self.cfg_dict["task"]["test"] = self.cfg.test # register the rl-games adapter to use inside the runner vecenv.register('RLGPU', lambda config_name, num_actors, **kwargs: RLGPUEnv(config_name, num_actors, **kwargs)) env_configurations.register('rlgpu', { 'vecenv_type': 'RLGPU', 'env_creator': lambda **kwargs: env }) self.rlg_config_dict = omegaconf_to_dict(self.cfg.train) def run(self): # create runner and set the settings runner = Runner(RLGPUAlgoObserver()) runner.load(copy.deepcopy(self.rlg_config_dict)) runner.reset() # dump config dict experiment_dir = os.path.join('runs', self.cfg.train.params.config.name) os.makedirs(experiment_dir, exist_ok=True) with open(os.path.join(experiment_dir, 'config.yaml'), 'w') as f: f.write(OmegaConf.to_yaml(self.cfg)) time_str = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") if self.cfg.wandb_activate: # Make sure to install WandB if you actually use this. import wandb run_name = f"{self.cfg.wandb_name}_{time_str}" wandb.init( project=self.cfg.wandb_project, group=self.cfg.wandb_group, entity=self.cfg.wandb_entity, config=self.cfg_dict, sync_tensorboard=True, id=run_name, resume="allow", monitor_gym=True, ) runner.run({ 'train': not self.cfg.test, 'play': self.cfg.test, 'checkpoint': self.cfg.checkpoint, 'sigma': None }) if self.cfg.wandb_activate: wandb.finish() class Trainer(TrainerMT): def __init__(self, trainer, env): self.ppo_thread = None self.action_queue = None self.data_queue = None self.trainer = trainer self.is_running = False self.env = env self.create_task() self.run() def create_task(self): self.trainer.launch_rlg_hydra(self.env) task = initialize_task(self.trainer.cfg_dict, self.env, init_sim=False) self.task = task def run(self): self.is_running = True self.action_queue = queue.Queue(1) self.data_queue = queue.Queue(1) if "mt_timeout" in self.trainer.cfg_dict: self.env.initialize(self.action_queue, self.data_queue, self.trainer.cfg_dict["mt_timeout"]) else: self.env.initialize(self.action_queue, self.data_queue) self.ppo_thread = PPOTrainer(self.env, self.task, self.trainer) self.ppo_thread.daemon = True self.ppo_thread.start() def stop(self): self.env.stop = True self.env.clear_queues() if self.action_queue: self.action_queue.join() if self.data_queue: self.data_queue.join() if self.ppo_thread: self.ppo_thread.join() self.action_queue = None self.data_queue = None self.ppo_thread = None self.is_running = False class PPOTrainer(threading.Thread): def __init__(self, env, task, trainer): super().__init__() self.env = env self.task = task self.trainer = trainer def run(self): from omni.isaac.gym.vec_env import TaskStopException print("starting ppo...") try: self.trainer.run() # trainer finished - send stop signal to main thread self.env.send_actions(None) self.env.stop = True except TaskStopException: print("Task Stopped!") @hydra.main(config_name="config", config_path="../cfg") def parse_hydra_configs(cfg: DictConfig): headless = cfg.headless env = IsaacEnvRlgamesMT(headless=headless, sim_device=cfg.device_id) # ensure checkpoints can be specified as relative paths 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 rlg_trainer = RLGTrainer(cfg, cfg_dict) trainer = Trainer(rlg_trainer, env) trainer.env.run(trainer) if __name__ == '__main__': parse_hydra_configs()
7,180
Python
33.524038
116
0.651114
makolon/hsr_isaac_tamp/hsr_rl/scripts/train_rlgames.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 os import torch import hydra import datetime from omegaconf import DictConfig from rl_games.common import env_configurations, vecenv from rl_games.torch_runner import Runner 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.rlgames.rlgames_utils import RLGPUAlgoObserver, RLGPUEnv from hsr_rl.utils.task_utils import initialize_task from hsr_rl.envs.isaac_env_rlgames import IsaacEnvRlgames class RLGTrainer(): def __init__(self, cfg, cfg_dict): self.cfg = cfg self.cfg_dict = cfg_dict def launch_rlg_hydra(self, env): # `create_rlgpu_env` is environment construction function which is passed to RL Games and called internally. # We use the helper function here to specify the environment config. self.cfg_dict["task"]["test"] = self.cfg.test # register the rl-games adapter to use inside the runner vecenv.register('RLGPU', lambda config_name, num_actors, **kwargs: RLGPUEnv(config_name, num_actors, **kwargs)) env_configurations.register('rlgpu', { 'vecenv_type': 'RLGPU', 'env_creator': lambda **kwargs: env }) self.rlg_config_dict = omegaconf_to_dict(self.cfg.train) def run(self): # create runner and set the settings runner = Runner(RLGPUAlgoObserver()) runner.load(self.rlg_config_dict) runner.reset() # dump config dict experiment_dir = os.path.join('runs', self.cfg.train.params.config.name) os.makedirs(experiment_dir, exist_ok=True) with open(os.path.join(experiment_dir, 'config.yaml'), 'w') as f: f.write(OmegaConf.to_yaml(self.cfg)) runner.run({ 'train': not self.cfg.test, 'play': self.cfg.test, 'checkpoint': self.cfg.checkpoint, 'sigma': None }) @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 rank = int(os.getenv("LOCAL_RANK", "0")) if cfg.multi_gpu: cfg.device_id = rank cfg.rl_device = f'cuda:{rank}' env = IsaacEnvRlgames(headless=headless, sim_device=cfg.device_id) # 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 and rank == 0: # 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, name=run_name, resume="allow", ) rlg_trainer = RLGTrainer(cfg, cfg_dict) rlg_trainer.launch_rlg_hydra(env) rlg_trainer.run() env.close() if cfg.wandb_activate and rank == 0: wandb.finish() if __name__ == '__main__': parse_hydra_configs()
5,203
Python
37.264706
116
0.681145
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/scripts/sample_rlgames.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.envs.isaac_env_rlgames import IsaacEnvRlgames @hydra.main(config_name="config", config_path="../cfg") def parse_hydra_configs(cfg: DictConfig): cfg_dict = omegaconf_to_dict(cfg) print_dict(cfg_dict) 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) # 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) actions = torch.tensor(np.array([np.random.uniform(env.action_space.low, env.action_space.high) 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()
1,758
Python
34.897958
162
0.666098
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/task_utils.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. def initialize_task(config, env, init_sim=True): from .config_utils.sim_config import SimConfig sim_config = SimConfig(config) from hsr_rl.tasks.example.hsr_reach import HSRExampleReachTask from hsr_rl.tasks.example.hsr_pick import HSRExamplePickTask from hsr_rl.tasks.example.hsr_place import HSRExamplePlaceTask from hsr_rl.tasks.example.hsr_insert import HSRExampleInsertTask from hsr_rl.tasks.example.hsr_cabinet import HSRExampleCabinetTask from hsr_rl.tasks.residual.hsr_residual_lift import HSRResidualLiftTask from hsr_rl.tasks.residual.hsr_residual_stack import HSRResidualStackTask # Mappings from strings to environments task_map = { "HSRExampleReach": HSRExampleReachTask, "HSRExamplePick": HSRExamplePickTask, "HSRExamplePlace": HSRExamplePlaceTask, "HSRExampleInsert": HSRExampleInsertTask, "HSRExampleCabinet": HSRExampleCabinetTask, "HSRResidualLift": HSRResidualLiftTask, "HSRResidualStack": HSRResidualStackTask, } cfg = sim_config.config task = task_map[cfg["task_name"]]( name=cfg["task_name"], sim_config=sim_config, env=env ) env.set_task(task=task, sim_params=sim_config.get_physics_params(), backend="torch", init_sim=init_sim) return task
2,861
Python
45.918032
107
0.759525
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/demo_utils.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. def initialize_demo(config, env, init_sim=True): from hsr_rl.demos.anymal_terrain import AnymalTerrainDemo # Mappings from strings to environments task_map = { "AnymalTerrain": AnymalTerrainDemo, } from hsr_rl.utils.config_utils.sim_config import SimConfig sim_config = SimConfig(config) cfg = sim_config.config task = task_map[cfg["task_name"]]( name=cfg["task_name"], sim_config=sim_config, env=env ) env.set_task(task=task, sim_params=sim_config.get_physics_params(), backend="torch", init_sim=init_sim) return
2,143
Python
43.666666
107
0.753616
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/domain_randomization/randomize.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 copy import omni import omni.replicator.core as rep import omni.replicator.isaac as dr import numpy as np import torch from omni.isaac.core.prims import RigidPrimView class Randomizer(): def __init__(self, sim_config): self._cfg = sim_config.task_config self._config = sim_config.config self.randomize = False dr_config = self._cfg.get("domain_randomization", None) self.distributions = dict() self.active_domain_randomizations = dict() self._observations_dr_params = None self._actions_dr_params = None if dr_config is not None: randomize = dr_config.get("randomize", False) randomization_params = dr_config.get("randomization_params", None) if randomize and randomization_params is not None: self.randomize = True self.min_frequency = dr_config.get("min_frequency", 1) def apply_on_startup_domain_randomization(self, task): if self.randomize: torch.manual_seed(self._config["seed"]) randomization_params = self._cfg["domain_randomization"]["randomization_params"] for opt in randomization_params.keys(): if opt == "rigid_prim_views": if randomization_params["rigid_prim_views"] is not None: for view_name in randomization_params["rigid_prim_views"].keys(): if randomization_params["rigid_prim_views"][view_name] is not None: for attribute, params in randomization_params["rigid_prim_views"][view_name].items(): params = randomization_params["rigid_prim_views"][view_name][attribute] if attribute in ["scale", "mass", "density"] and params is not None: if "on_startup" in params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(params["on_startup"]): raise ValueError(f"Please ensure the following randomization parameters for {view_name} {attribute} " + \ "on_startup are provided: operation, distribution, distribution_parameters.") view = task._env._world.scene._scene_registry.rigid_prim_views[view_name] if attribute == "scale": self.randomize_scale_on_startup( view=view, distribution=params["on_startup"]["distribution"], distribution_parameters=params["on_startup"]["distribution_parameters"], operation=params["on_startup"]["operation"], sync_dim_noise=True, ) elif attribute == "mass": self.randomize_mass_on_startup( view=view, distribution=params["on_startup"]["distribution"], distribution_parameters=params["on_startup"]["distribution_parameters"], operation=params["on_startup"]["operation"], ) elif attribute == "density": self.randomize_density_on_startup( view=view, distribution=params["on_startup"]["distribution"], distribution_parameters=params["on_startup"]["distribution_parameters"], operation=params["on_startup"]["operation"], ) if opt == "articulation_views": if randomization_params["articulation_views"] is not None: for view_name in randomization_params["articulation_views"].keys(): if randomization_params["articulation_views"][view_name] is not None: for attribute, params in randomization_params["articulation_views"][view_name].items(): params = randomization_params["articulation_views"][view_name][attribute] if attribute in ["scale"] and params is not None: if "on_startup" in params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(params["on_startup"]): raise ValueError(f"Please ensure the following randomization parameters for {view_name} {attribute} " + \ "on_startup are provided: operation, distribution, distribution_parameters.") view = task._env._world.scene._scene_registry.articulated_views[view_name] if attribute == "scale": self.randomize_scale_on_startup( view=view, distribution=params["on_startup"]["distribution"], distribution_parameters=params["on_startup"]["distribution_parameters"], operation=params["on_startup"]["operation"], sync_dim_noise=True ) else: dr_config = self._cfg.get("domain_randomization", None) if dr_config is None: raise ValueError("No domain randomization parameters are specified in the task yaml config file") randomize = dr_config.get("randomize", False) randomization_params = dr_config.get("randomization_params", None) if randomize == False or randomization_params is None: print("On Startup Domain randomization will not be applied.") def set_up_domain_randomization(self, task): if self.randomize: randomization_params = self._cfg["domain_randomization"]["randomization_params"] rep.set_global_seed(self._config["seed"]) with dr.trigger.on_rl_frame(num_envs=self._cfg["env"]["numEnvs"]): for opt in randomization_params.keys(): if opt == "observations": self._set_up_observations_randomization(task) elif opt == "actions": self._set_up_actions_randomization(task) elif opt == "simulation": if randomization_params["simulation"] is not None: self.distributions["simulation"] = dict() dr.physics_view.register_simulation_context(task._env._world) for attribute, params in randomization_params["simulation"].items(): self._set_up_simulation_randomization(attribute, params) elif opt == "rigid_prim_views": if randomization_params["rigid_prim_views"] is not None: self.distributions["rigid_prim_views"] = dict() for view_name in randomization_params["rigid_prim_views"].keys(): if randomization_params["rigid_prim_views"][view_name] is not None: self.distributions["rigid_prim_views"][view_name] = dict() dr.physics_view.register_rigid_prim_view( rigid_prim_view=task._env._world.scene._scene_registry.rigid_prim_views[view_name], ) for attribute, params in randomization_params["rigid_prim_views"][view_name].items(): if attribute not in ["scale", "density"]: self._set_up_rigid_prim_view_randomization(view_name, attribute, params) elif opt == "articulation_views": if randomization_params["articulation_views"] is not None: self.distributions["articulation_views"] = dict() for view_name in randomization_params["articulation_views"].keys(): if randomization_params["articulation_views"][view_name] is not None: self.distributions["articulation_views"][view_name] = dict() dr.physics_view.register_articulation_view( articulation_view=task._env._world.scene._scene_registry.articulated_views[view_name], ) for attribute, params in randomization_params["articulation_views"][view_name].items(): if attribute not in ["scale"]: self._set_up_articulation_view_randomization(view_name, attribute, params) rep.orchestrator.run() else: dr_config = self._cfg.get("domain_randomization", None) if dr_config is None: raise ValueError("No domain randomization parameters are specified in the task yaml config file") randomize = dr_config.get("randomize", False) randomization_params = dr_config.get("randomization_params", None) if randomize == False or randomization_params is None: print("Domain randomization will not be applied.") def _set_up_observations_randomization(self, task): task.randomize_observations = True self._observations_dr_params = self._cfg["domain_randomization"]["randomization_params"]["observations"] if self._observations_dr_params is None: raise ValueError(f"Observations randomization parameters are not provided.") if "on_reset" in self._observations_dr_params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(self._observations_dr_params["on_reset"].keys()): raise ValueError(f"Please ensure the following observations on_reset randomization parameters are provided: " + \ "operation, distribution, distribution_parameters.") self.active_domain_randomizations[("observations", "on_reset")] = np.array(self._observations_dr_params["on_reset"]["distribution_parameters"]) if "on_interval" in self._observations_dr_params.keys(): if not set(('frequency_interval', 'operation','distribution', 'distribution_parameters')).issubset(self._observations_dr_params["on_interval"].keys()): raise ValueError(f"Please ensure the following observations on_interval randomization parameters are provided: " + \ "frequency_interval, operation, distribution, distribution_parameters.") self.active_domain_randomizations[("observations", "on_interval")] = np.array(self._observations_dr_params["on_interval"]["distribution_parameters"]) self._observations_counter_buffer = torch.zeros((self._cfg["env"]["numEnvs"]), dtype=torch.int, device=self._config["rl_device"]) self._observations_correlated_noise = torch.zeros((self._cfg["env"]["numEnvs"], task.num_observations), device=self._config["rl_device"]) def _set_up_actions_randomization(self, task): task.randomize_actions = True self._actions_dr_params = self._cfg["domain_randomization"]["randomization_params"]["actions"] if self._actions_dr_params is None: raise ValueError(f"Actions randomization parameters are not provided.") if "on_reset" in self._actions_dr_params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(self._actions_dr_params["on_reset"].keys()): raise ValueError(f"Please ensure the following actions on_reset randomization parameters are provided: " + \ "operation, distribution, distribution_parameters.") self.active_domain_randomizations[("actions", "on_reset")] = np.array(self._actions_dr_params["on_reset"]["distribution_parameters"]) if "on_interval" in self._actions_dr_params.keys(): if not set(('frequency_interval', 'operation','distribution', 'distribution_parameters')).issubset(self._actions_dr_params["on_interval"].keys()): raise ValueError(f"Please ensure the following actions on_interval randomization parameters are provided: " + \ "frequency_interval, operation, distribution, distribution_parameters.") self.active_domain_randomizations[("actions", "on_interval")] = np.array(self._actions_dr_params["on_interval"]["distribution_parameters"]) self._actions_counter_buffer = torch.zeros((self._cfg["env"]["numEnvs"]), dtype=torch.int, device=self._config["rl_device"]) self._actions_correlated_noise = torch.zeros((self._cfg["env"]["numEnvs"], task.num_actions), device=self._config["rl_device"]) def apply_observations_randomization(self, observations, reset_buf): env_ids = reset_buf.nonzero(as_tuple=False).squeeze(-1) self._observations_counter_buffer[env_ids] = 0 self._observations_counter_buffer += 1 if "on_reset" in self._observations_dr_params.keys(): observations[:] = self._apply_correlated_noise( buffer_type="observations", buffer=observations, reset_ids=env_ids, operation=self._observations_dr_params["on_reset"]["operation"], distribution=self._observations_dr_params["on_reset"]["distribution"], distribution_parameters=self._observations_dr_params["on_reset"]["distribution_parameters"], ) if "on_interval" in self._observations_dr_params.keys(): randomize_ids = (self._observations_counter_buffer >= self._observations_dr_params["on_interval"]["frequency_interval"]).nonzero(as_tuple=False).squeeze(-1) self._observations_counter_buffer[randomize_ids] = 0 observations[:] = self._apply_uncorrelated_noise( buffer=observations, randomize_ids=randomize_ids, operation=self._observations_dr_params["on_interval"]["operation"], distribution=self._observations_dr_params["on_interval"]["distribution"], distribution_parameters=self._observations_dr_params["on_interval"]["distribution_parameters"], ) return observations def apply_actions_randomization(self, actions, reset_buf): env_ids = reset_buf.nonzero(as_tuple=False).squeeze(-1) self._actions_counter_buffer[env_ids] = 0 self._actions_counter_buffer += 1 if "on_reset" in self._actions_dr_params.keys(): actions[:] = self._apply_correlated_noise( buffer_type="actions", buffer=actions, reset_ids=env_ids, operation=self._actions_dr_params["on_reset"]["operation"], distribution=self._actions_dr_params["on_reset"]["distribution"], distribution_parameters=self._actions_dr_params["on_reset"]["distribution_parameters"], ) if "on_interval" in self._actions_dr_params.keys(): randomize_ids = (self._actions_counter_buffer >= self._actions_dr_params["on_interval"]["frequency_interval"]).nonzero(as_tuple=False).squeeze(-1) self._actions_counter_buffer[randomize_ids] = 0 actions[:] = self._apply_uncorrelated_noise( buffer=actions, randomize_ids=randomize_ids, operation=self._actions_dr_params["on_interval"]["operation"], distribution=self._actions_dr_params["on_interval"]["distribution"], distribution_parameters=self._actions_dr_params["on_interval"]["distribution_parameters"], ) return actions def _apply_uncorrelated_noise(self, buffer, randomize_ids, operation, distribution, distribution_parameters): if distribution == "gaussian" or distribution == "normal": noise = torch.normal(mean=distribution_parameters[0], std=distribution_parameters[1], size=(len(randomize_ids), buffer.shape[1]), device=self._config["rl_device"]) elif distribution == "uniform": noise = (distribution_parameters[1] - distribution_parameters[0]) * torch.rand((len(randomize_ids), buffer.shape[1]), device=self._config["rl_device"]) + distribution_parameters[0] elif distribution == "loguniform" or distribution == "log_uniform": noise = torch.exp((np.log(distribution_parameters[1]) - np.log(distribution_parameters[0])) * torch.rand((len(randomize_ids), buffer.shape[1]), device=self._config["rl_device"]) + np.log(distribution_parameters[0])) else: print(f"The specified {distribution} distribution is not supported.") if operation == "additive": buffer[randomize_ids] += noise elif operation == "scaling": buffer[randomize_ids] *= noise else: print(f"The specified {operation} operation type is not supported.") return buffer def _apply_correlated_noise(self, buffer_type, buffer, reset_ids, operation, distribution, distribution_parameters): if buffer_type == "observations": correlated_noise_buffer = self._observations_correlated_noise elif buffer_type == "actions": correlated_noise_buffer = self._actions_correlated_noise if len(reset_ids) > 0: if distribution == "gaussian" or distribution == "normal": correlated_noise_buffer[reset_ids] = torch.normal(mean=distribution_parameters[0], std=distribution_parameters[1], size=(len(reset_ids), buffer.shape[1]), device=self._config["rl_device"]) elif distribution == "uniform": correlated_noise_buffer[reset_ids] = (distribution_parameters[1] - distribution_parameters[0]) * torch.rand((len(reset_ids), buffer.shape[1]), device=self._config["rl_device"]) + distribution_parameters[0] elif distribution == "loguniform" or distribution == "log_uniform": correlated_noise_buffer[reset_ids] = torch.exp((np.log(distribution_parameters[1]) - np.log(distribution_parameters[0])) * torch.rand((len(reset_ids), buffer.shape[1]), device=self._config["rl_device"]) + np.log(distribution_parameters[0])) else: print(f"The specified {distribution} distribution is not supported.") if operation == "additive": buffer += correlated_noise_buffer elif operation == "scaling": buffer *= correlated_noise_buffer else: print(f"The specified {operation} operation type is not supported.") return buffer def _set_up_simulation_randomization(self, attribute, params): if params is None: raise ValueError(f"Randomization parameters for simulation {attribute} is not provided.") if attribute in dr.SIMULATION_CONTEXT_ATTRIBUTES: self.distributions["simulation"][attribute] = dict() if "on_reset" in params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(params["on_reset"]): raise ValueError(f"Please ensure the following randomization parameters for simulation {attribute} on_reset are provided: " + \ "operation, distribution, distribution_parameters.") self.active_domain_randomizations[("simulation", attribute, "on_reset")] = np.array(params["on_reset"]["distribution_parameters"]) kwargs = {"operation": params["on_reset"]["operation"]} self.distributions["simulation"][attribute]["on_reset"] = self._generate_distribution( dimension=dr.physics_view._simulation_context_initial_values[attribute].shape[0], view_name="simulation", attribute=attribute, params=params["on_reset"], ) kwargs[attribute] = self.distributions["simulation"][attribute]["on_reset"] with dr.gate.on_env_reset(): dr.physics_view.randomize_simulation_context(**kwargs) if "on_interval" in params.keys(): if not set(('frequency_interval', 'operation','distribution', 'distribution_parameters')).issubset(params["on_interval"]): raise ValueError(f"Please ensure the following randomization parameters for simulation {attribute} on_interval are provided: " + \ "frequency_interval, operation, distribution, distribution_parameters.") self.active_domain_randomizations[("simulation", attribute, "on_interval")] = np.array(params["on_interval"]["distribution_parameters"]) kwargs = {"operation": params["on_interval"]["operation"]} self.distributions["simulation"][attribute]["on_interval"] = self._generate_distribution( dimension=dr.physics_view._simulation_context_initial_values[attribute].shape[0], view_name="simulation", attribute=attribute, params=params["on_interval"], ) kwargs[attribute] = self.distributions["simulation"][attribute]["on_interval"] with dr.gate.on_interval(interval=params["on_interval"]["frequency_interval"]): dr.physics_view.randomize_simulation_context(**kwargs) def _set_up_rigid_prim_view_randomization(self, view_name, attribute, params): if params is None: raise ValueError(f"Randomization parameters for rigid prim view {view_name} {attribute} is not provided.") if attribute in dr.RIGID_PRIM_ATTRIBUTES: self.distributions["rigid_prim_views"][view_name][attribute] = dict() if "on_reset" in params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(params["on_reset"]): raise ValueError(f"Please ensure the following randomization parameters for {view_name} {attribute} on_reset are provided: " + \ "operation, distribution, distribution_parameters.") self.active_domain_randomizations[("rigid_prim_views", view_name, attribute, "on_reset")] = np.array(params["on_reset"]["distribution_parameters"]) kwargs = {"view_name": view_name, "operation": params["on_reset"]["operation"]} if attribute == "material_properties" and "num_buckets" in params["on_reset"].keys(): kwargs["num_buckets"] = params["on_reset"]["num_buckets"] self.distributions["rigid_prim_views"][view_name][attribute]["on_reset"] = self._generate_distribution( dimension=dr.physics_view._rigid_prim_views_initial_values[view_name][attribute].shape[1], view_name=view_name, attribute=attribute, params=params["on_reset"], ) kwargs[attribute] = self.distributions["rigid_prim_views"][view_name][attribute]["on_reset"] with dr.gate.on_env_reset(): dr.physics_view.randomize_rigid_prim_view(**kwargs) if "on_interval" in params.keys(): if not set(('frequency_interval', 'operation','distribution', 'distribution_parameters')).issubset(params["on_interval"]): raise ValueError(f"Please ensure the following randomization parameters for {view_name} {attribute} on_interval are provided: " + \ "frequency_interval, operation, distribution, distribution_parameters.") self.active_domain_randomizations[("rigid_prim_views", view_name, attribute, "on_interval")] = np.array(params["on_interval"]["distribution_parameters"]) kwargs = {"view_name": view_name, "operation": params["on_interval"]["operation"]} if attribute == "material_properties" and "num_buckets" in params["on_interval"].keys(): kwargs["num_buckets"] = params["on_interval"]["num_buckets"] self.distributions["rigid_prim_views"][view_name][attribute]["on_interval"] = self._generate_distribution( dimension=dr.physics_view._rigid_prim_views_initial_values[view_name][attribute].shape[1], view_name=view_name, attribute=attribute, params=params["on_interval"], ) kwargs[attribute] = self.distributions["rigid_prim_views"][view_name][attribute]["on_interval"] with dr.gate.on_interval(interval=params["on_interval"]["frequency_interval"]): dr.physics_view.randomize_rigid_prim_view(**kwargs) else: raise ValueError(f"The attribute {attribute} for {view_name} is invalid for domain randomization.") def _set_up_articulation_view_randomization(self, view_name, attribute, params): if params is None: raise ValueError(f"Randomization parameters for articulation view {view_name} {attribute} is not provided.") if attribute in dr.ARTICULATION_ATTRIBUTES: self.distributions["articulation_views"][view_name][attribute] = dict() if "on_reset" in params.keys(): if not set(('operation','distribution', 'distribution_parameters')).issubset(params["on_reset"]): raise ValueError(f"Please ensure the following randomization parameters for {view_name} {attribute} on_reset are provided: " + \ "operation, distribution, distribution_parameters.") self.active_domain_randomizations[("articulation_views", view_name, attribute, "on_reset")] = np.array(params["on_reset"]["distribution_parameters"]) kwargs = {"view_name": view_name, "operation": params["on_reset"]["operation"]} if attribute == "material_properties" and "num_buckets" in params["on_reset"].keys(): kwargs["num_buckets"] = params["on_reset"]["num_buckets"] self.distributions["articulation_views"][view_name][attribute]["on_reset"] = self._generate_distribution( dimension=dr.physics_view._articulation_views_initial_values[view_name][attribute].shape[1], view_name=view_name, attribute=attribute, params=params["on_reset"], ) kwargs[attribute] = self.distributions["articulation_views"][view_name][attribute]["on_reset"] with dr.gate.on_env_reset(): dr.physics_view.randomize_articulation_view(**kwargs) if "on_interval" in params.keys(): if not set(('frequency_interval', 'operation','distribution', 'distribution_parameters')).issubset(params["on_interval"]): raise ValueError(f"Please ensure the following randomization parameters for {view_name} {attribute} on_interval are provided: " + \ "frequency_interval, operation, distribution, distribution_parameters.") self.active_domain_randomizations[("articulation_views", view_name, attribute, "on_interval")] = np.array(params["on_interval"]["distribution_parameters"]) kwargs = {"view_name": view_name, "operation": params["on_interval"]["operation"]} if attribute == "material_properties" and "num_buckets" in params["on_interval"].keys(): kwargs["num_buckets"] = params["on_interval"]["num_buckets"] self.distributions["articulation_views"][view_name][attribute]["on_interval"] = self._generate_distribution( dimension=dr.physics_view._articulation_views_initial_values[view_name][attribute].shape[1], view_name=view_name, attribute=attribute, params=params["on_interval"], ) kwargs[attribute] = self.distributions["articulation_views"][view_name][attribute]["on_interval"] with dr.gate.on_interval(interval=params["on_interval"]["frequency_interval"]): dr.physics_view.randomize_articulation_view(**kwargs) else: raise ValueError(f"The attribute {attribute} for {view_name} is invalid for domain randomization.") def _generate_distribution(self, view_name, attribute, dimension, params): dist_params = self._sanitize_distribution_parameters(attribute, dimension, params["distribution_parameters"]) if params["distribution"] == "uniform": return rep.distribution.uniform(tuple(dist_params[0]), tuple(dist_params[1])) elif params["distribution"] == "gaussian" or params["distribution"] == "normal": return rep.distribution.normal(tuple(dist_params[0]), tuple(dist_params[1])) elif params["distribution"] == "loguniform" or params["distribution"] == "log_uniform": return rep.distribution.log_uniform(tuple(dist_params[0]), tuple(dist_params[1])) else: raise ValueError(f"The provided distribution for {view_name} {attribute} is not supported. " + "Options: uniform, gaussian/normal, loguniform/log_uniform" ) def _sanitize_distribution_parameters(self, attribute, dimension, params): distribution_parameters = np.array(params) if distribution_parameters.shape == (2,): # if the user does not provide a set of parameters for each dimension dist_params = [[distribution_parameters[0]]*dimension, [distribution_parameters[1]]*dimension] elif distribution_parameters.shape == (2, dimension): # if the user provides a set of parameters for each dimension in the format [[...], [...]] dist_params = distribution_parameters.tolist() elif attribute in ["material_properties", "body_inertias"] and distribution_parameters.shape == (2, 3): # if the user only provides the parameters for one body in the articulation, assume the same parameters for all other links dist_params = [[distribution_parameters[0]] * (dimension // 3), [distribution_parameters[1]] * (dimension // 3)] else: raise ValueError(f"The provided distribution_parameters for {view_name} {attribute} is invalid due to incorrect dimensions.") return dist_params def set_dr_distribution_parameters(self, distribution_parameters, *distribution_path): if distribution_path not in self.active_domain_randomizations.keys(): raise ValueError(f"Cannot find a valid domain randomization distribution using the path {distribution_path}.") if distribution_path[0] == "observations": if len(distribution_parameters) == 2: self._observations_dr_params[distribution_path[1]]["distribution_parameters"] = distribution_parameters else: raise ValueError(f"Please provide distribution_parameters for observations {distribution_path[1]} " + "in the form of [dist_param_1, dist_param_2]") elif distribution_path[0] == "actions": if len(distribution_parameters) == 2: self._actions_dr_params[distribution_path[1]]["distribution_parameters"] = distribution_parameters else: raise ValueError(f"Please provide distribution_parameters for actions {distribution_path[1]} " + "in the form of [dist_param_1, dist_param_2]") else: replicator_distribution = self.distributions[distribution_path[0]][distribution_path[1]][distribution_path[2]] if distribution_path[0] == "rigid_prim_views" or distribution_path[0] == "articulation_views": replicator_distribution = replicator_distribution[distribution_path[3]] if replicator_distribution.node.get_node_type().get_node_type() == "omni.replicator.core.OgnSampleUniform" \ or replicator_distribution.node.get_node_type().get_node_type() == "omni.replicator.core.OgnSampleLogUniform": dimension = len(dr.utils.get_distribution_params(replicator_distribution, ["lower"])[0]) dist_params = self._sanitize_distribution_parameters(distribution_path[-2], dimension, distribution_parameters) dr.utils.set_distribution_params(replicator_distribution, {"lower": dist_params[0], "upper": dist_params[1]}) elif replicator_distribution.node.get_node_type().get_node_type() == "omni.replicator.core.OgnSampleNormal": dimension = len(dr.utils.get_distribution_params(replicator_distribution, ["mean"])[0]) dist_params = self._sanitize_distribution_parameters(distribution_path[-2], dimension, distribution_parameters) dr.utils.set_distribution_params(replicator_distribution, {"mean": dist_params[0], "std": dist_params[1]}) def get_dr_distribution_parameters(self, *distribution_path): if distribution_path not in self.active_domain_randomizations.keys(): raise ValueError(f"Cannot find a valid domain randomization distribution using the path {distribution_path}.") if distribution_path[0] == "observations": return self._observations_dr_params[distribution_path[1]]["distribution_parameters"] elif distribution_path[0] == "actions": return self._actions_dr_params[distribution_path[1]]["distribution_parameters"] else: replicator_distribution = self.distributions[distribution_path[0]][distribution_path[1]][distribution_path[2]] if distribution_path[0] == "rigid_prim_views" or distribution_path[0] == "articulation_views": replicator_distribution = replicator_distribution[distribution_path[3]] if replicator_distribution.node.get_node_type().get_node_type() == "omni.replicator.core.OgnSampleUniform" \ or replicator_distribution.node.get_node_type().get_node_type() == "omni.replicator.core.OgnSampleLogUniform": return dr.utils.get_distribution_params(replicator_distribution, ["lower", "upper"]) elif replicator_distribution.node.get_node_type().get_node_type() == "omni.replicator.core.OgnSampleNormal": return dr.utils.get_distribution_params(replicator_distribution, ["mean", "std"]) def get_initial_dr_distribution_parameters(self, *distribution_path): if distribution_path not in self.active_domain_randomizations.keys(): raise ValueError(f"Cannot find a valid domain randomization distribution using the path {distribution_path}.") return self.active_domain_randomizations[distribution_path].copy() def _generate_noise(self, distribution, distribution_parameters, size, device): if distribution == "gaussian" or distribution == "normal": noise = torch.normal(mean=distribution_parameters[0], std=distribution_parameters[1], size=size, device=device) elif distribution == "uniform": noise = (distribution_parameters[1] - distribution_parameters[0]) * torch.rand(size, device=device) + distribution_parameters[0] elif distribution == "loguniform" or distribution == "log_uniform": noise = torch.exp((np.log(distribution_parameters[1]) - np.log(distribution_parameters[0])) * torch.rand(size, device=device) + np.log(distribution_parameters[0])) else: print(f"The specified {distribution} distribution is not supported.") return noise def randomize_scale_on_startup(self, view, distribution, distribution_parameters, operation, sync_dim_noise=True): scales = view.get_local_scales() if sync_dim_noise: dist_params = np.asarray(self._sanitize_distribution_parameters(attribute="scale", dimension=1, params=distribution_parameters)) noise = self._generate_noise(distribution, dist_params.squeeze(), (view.count,), view._device).repeat(3,1).T else: dist_params = np.asarray(self._sanitize_distribution_parameters(attribute="scale", dimension=3, params=distribution_parameters)) noise = torch.zeros((view.count, 3), device=view._device) for i in range(3): noise[:, i] = self._generate_noise(distribution, dist_params[:, i], (view.count,), view._device) if operation == "additive": scales += noise elif operation == "scaling": scales *= noise elif operation == "direct": scales = noise else: print(f"The specified {operation} operation type is not supported.") view.set_local_scales(scales=scales) def randomize_mass_on_startup(self, view, distribution, distribution_parameters, operation): if isinstance(view, omni.isaac.core.prims.RigidPrimView) or isinstance(view, RigidPrimView): masses = view.get_masses() dist_params = np.asarray(self._sanitize_distribution_parameters(attribute=f"{view.name} mass", dimension=1, params=distribution_parameters)) noise = self._generate_noise(distribution, dist_params.squeeze(), (view.count,), view._device) set_masses = view.set_masses if operation == "additive": masses += noise elif operation == "scaling": masses *= noise elif operation == "direct": masses = noise else: print(f"The specified {operation} operation type is not supported.") set_masses(masses) def randomize_density_on_startup(self, view, distribution, distribution_parameters, operation): if isinstance(view, omni.isaac.core.prims.RigidPrimView) or isinstance(view, RigidPrimView): densities = view.get_densities() dist_params = np.asarray(self._sanitize_distribution_parameters(attribute=f"{view.name} density", dimension=1, params=distribution_parameters)) noise = self._generate_noise(distribution, dist_params.squeeze(), (view.count,), view._device) set_densities = view.set_densities if operation == "additive": densities += noise elif operation == "scaling": densities *= noise elif operation == "direct": densities = noise else: print(f"The specified {operation} operation type is not supported.") set_densities(densities)
41,563
Python
70.910034
256
0.602892
makolon/hsr_isaac_tamp/hsr_rl/utils/rlgames/rlgames_utils.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 rl_games.common import env_configurations, vecenv from rl_games.common.algo_observer import AlgoObserver from rl_games.algos_torch import torch_ext import torch import numpy as np from typing import Callable class RLGPUAlgoObserver(AlgoObserver): """Allows us to log stats from the env along with the algorithm running stats. """ def __init__(self): pass def after_init(self, algo): self.algo = algo self.mean_scores = torch_ext.AverageMeter(1, self.algo.games_to_track).to(self.algo.ppo_device) self.ep_infos = [] self.direct_info = {} self.writer = self.algo.writer def process_infos(self, infos, done_indices): assert isinstance(infos, dict), "RLGPUAlgoObserver expects dict info" if isinstance(infos, dict): if 'episode' in infos: self.ep_infos.append(infos['episode']) if len(infos) > 0 and isinstance(infos, dict): # allow direct logging from env self.direct_info = {} for k, v in infos.items(): # only log scalars if isinstance(v, float) or isinstance(v, int) or (isinstance(v, torch.Tensor) and len(v.shape) == 0): self.direct_info[k] = v def after_clear_stats(self): self.mean_scores.clear() def after_print_stats(self, frame, epoch_num, total_time): if self.ep_infos: for key in self.ep_infos[0]: infotensor = torch.tensor([], device=self.algo.device) for ep_info in self.ep_infos: # handle scalar and zero dimensional tensor infos if not isinstance(ep_info[key], torch.Tensor): ep_info[key] = torch.Tensor([ep_info[key]]) if len(ep_info[key].shape) == 0: ep_info[key] = ep_info[key].unsqueeze(0) infotensor = torch.cat((infotensor, ep_info[key].to(self.algo.device))) value = torch.mean(infotensor) self.writer.add_scalar('Episode/' + key, value, epoch_num) self.ep_infos.clear() for k, v in self.direct_info.items(): self.writer.add_scalar(f'{k}/frame', v, frame) self.writer.add_scalar(f'{k}/iter', v, epoch_num) self.writer.add_scalar(f'{k}/time', v, total_time) if self.mean_scores.current_size > 0: mean_scores = self.mean_scores.get_mean() self.writer.add_scalar('scores/mean', mean_scores, frame) self.writer.add_scalar('scores/iter', mean_scores, epoch_num) self.writer.add_scalar('scores/time', mean_scores, total_time) class RLGPUEnv(vecenv.IVecEnv): def __init__(self, config_name, num_actors, **kwargs): self.env = env_configurations.configurations[config_name]['env_creator'](**kwargs) def step(self, action): return self.env.step(action) def reset(self): return self.env.reset() def get_number_of_agents(self): return self.env.get_number_of_agents() def get_env_info(self): info = {} info['action_space'] = self.env.action_space info['observation_space'] = self.env.observation_space if self.env.num_states > 0: info['state_space'] = self.env.state_space print(info['action_space'], info['observation_space'], info['state_space']) else: print(info['action_space'], info['observation_space']) return info
5,152
Python
42.669491
121
0.642857
makolon/hsr_isaac_tamp/hsr_rl/utils/config_utils/sim_config.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.utils.config_utils.default_scene_params import * import copy import omni.usd import numpy as np import torch import carb class SimConfig(): def __init__(self, config: dict = None): if config is None: config = dict() self._config = config self._cfg = config.get("task", dict()) self._parse_config() if self._config["test"] == True: self._sim_params["enable_scene_query_support"] = True from omni.isaac.core.utils.extensions import enable_extension if self._config["headless"] == True and not self._sim_params["enable_cameras"] and not self._config["enable_livestream"]: self._sim_params["use_flatcache"] = False self._sim_params["enable_viewport"] = False else: self._sim_params["enable_viewport"] = True enable_extension("omni.kit.viewport.bundle") enable_extension("omni.replicator.isaac") if self._sim_params["disable_contact_processing"]: carb.settings.get_settings().set_bool("/physics/disableContactProcessing", True) carb.settings.get_settings().set_bool("/physics/physxDispatcher", True) def _parse_config(self): # general sim parameter self._sim_params = copy.deepcopy(default_sim_params) self._default_physics_material = copy.deepcopy(default_physics_material) sim_cfg = self._cfg.get("sim", None) if sim_cfg is not None: for opt in sim_cfg.keys(): if opt in self._sim_params: if opt == "default_physics_material": for material_opt in sim_cfg[opt]: self._default_physics_material[material_opt] = sim_cfg[opt][material_opt] else: self._sim_params[opt] = sim_cfg[opt] else: print("Sim params does not have attribute: ", opt) self._sim_params["default_physics_material"] = self._default_physics_material # physx parameters self._physx_params = copy.deepcopy(default_physx_params) if sim_cfg is not None and "physx" in sim_cfg: for opt in sim_cfg["physx"].keys(): if opt in self._physx_params: self._physx_params[opt] = sim_cfg["physx"][opt] else: print("Physx sim params does not have attribute: ", opt) self._sanitize_device() def _sanitize_device(self): if self._sim_params["use_gpu_pipeline"]: self._physx_params["use_gpu"] = True # device should be in sync with pipeline if self._sim_params["use_gpu_pipeline"]: self._config["sim_device"] = f"cuda:{self._config['device_id']}" else: self._config["sim_device"] = "cpu" # also write to physics params for setting sim device self._physx_params["sim_device"] = self._config["sim_device"] print("Pipeline: ", "GPU" if self._sim_params["use_gpu_pipeline"] else "CPU") print("Pipeline Device: ", self._config["sim_device"]) print("Sim Device: ", "GPU" if self._physx_params["use_gpu"] else "CPU") def parse_actor_config(self, actor_name): actor_params = copy.deepcopy(default_actor_options) if "sim" in self._cfg and actor_name in self._cfg["sim"]: actor_cfg = self._cfg["sim"][actor_name] for opt in actor_cfg.keys(): if actor_cfg[opt] != -1 and opt in actor_params: actor_params[opt] = actor_cfg[opt] elif opt not in actor_params: print("Actor params does not have attribute: ", opt) return actor_params def _get_actor_config_value(self, actor_name, attribute_name, attribute=None): actor_params = self.parse_actor_config(actor_name) if attribute is not None: if attribute_name not in actor_params: return attribute.Get() if actor_params[attribute_name] != -1: return actor_params[attribute_name] elif actor_params["override_usd_defaults"] and not attribute.IsAuthored(): return self._physx_params[attribute_name] else: if actor_params[attribute_name] != -1: return actor_params[attribute_name] @property def sim_params(self): return self._sim_params @property def config(self): return self._config @property def task_config(self): return self._cfg @property def physx_params(self): return self._physx_params def get_physics_params(self): return {**self.sim_params, **self.physx_params} def _get_physx_collision_api(self, prim): from pxr import UsdPhysics, PhysxSchema physx_collision_api = PhysxSchema.PhysxCollisionAPI(prim) if not physx_collision_api: physx_collision_api = PhysxSchema.PhysxCollisionAPI.Apply(prim) return physx_collision_api def _get_physx_rigid_body_api(self, prim): from pxr import UsdPhysics, PhysxSchema physx_rb_api = PhysxSchema.PhysxRigidBodyAPI(prim) if not physx_rb_api: physx_rb_api = PhysxSchema.PhysxRigidBodyAPI.Apply(prim) return physx_rb_api def _get_physx_articulation_api(self, prim): from pxr import UsdPhysics, PhysxSchema arti_api = PhysxSchema.PhysxArticulationAPI(prim) if not arti_api: arti_api = PhysxSchema.PhysxArticulationAPI.Apply(prim) return arti_api def set_contact_offset(self, name, prim, value=None): physx_collision_api = self._get_physx_collision_api(prim) contact_offset = physx_collision_api.GetContactOffsetAttr() # if not contact_offset: # contact_offset = physx_collision_api.CreateContactOffsetAttr() if value is None: value = self._get_actor_config_value(name, "contact_offset", contact_offset) if value != -1: contact_offset.Set(value) def set_rest_offset(self, name, prim, value=None): physx_collision_api = self._get_physx_collision_api(prim) rest_offset = physx_collision_api.GetRestOffsetAttr() # if not rest_offset: # rest_offset = physx_collision_api.CreateRestOffsetAttr() if value is None: value = self._get_actor_config_value(name, "rest_offset", rest_offset) if value != -1: rest_offset.Set(value) def set_position_iteration(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) solver_position_iteration_count = physx_rb_api.GetSolverPositionIterationCountAttr() if value is None: value = self._get_actor_config_value(name, "solver_position_iteration_count", solver_position_iteration_count) if value != -1: solver_position_iteration_count.Set(value) def set_velocity_iteration(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) solver_velocity_iteration_count = physx_rb_api.GetSolverVelocityIterationCountAttr() if value is None: value = self._get_actor_config_value(name, "solver_velocity_iteration_count", solver_velocity_iteration_count) if value != -1: solver_velocity_iteration_count.Set(value) def set_max_depenetration_velocity(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) max_depenetration_velocity = physx_rb_api.GetMaxDepenetrationVelocityAttr() if value is None: value = self._get_actor_config_value(name, "max_depenetration_velocity", max_depenetration_velocity) if value != -1: max_depenetration_velocity.Set(value) def set_sleep_threshold(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) sleep_threshold = physx_rb_api.GetSleepThresholdAttr() if value is None: value = self._get_actor_config_value(name, "sleep_threshold", sleep_threshold) if value != -1: sleep_threshold.Set(value) def set_stabilization_threshold(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) stabilization_threshold = physx_rb_api.GetStabilizationThresholdAttr() if value is None: value = self._get_actor_config_value(name, "stabilization_threshold", stabilization_threshold) if value != -1: stabilization_threshold.Set(value) def set_gyroscopic_forces(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) enable_gyroscopic_forces = physx_rb_api.GetEnableGyroscopicForcesAttr() if value is None: value = self._get_actor_config_value(name, "enable_gyroscopic_forces", enable_gyroscopic_forces) if value != -1: enable_gyroscopic_forces.Set(value) def set_density(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) density = physx_rb_api.GetDensityAttr() if value is None: value = self._get_actor_config_value(name, "density", density) if value != -1: density.Set(value) # auto-compute mass self.set_mass(prim, 0.0) def set_mass(self, name, prim, value=None): physx_rb_api = self._get_physx_rigid_body_api(prim) mass = physx_rb_api.GetMassAttr() if value is None: value = self._get_actor_config_value(name, "mass", mass) if value != -1: mass.Set(value) def retain_acceleration(self, prim): # retain accelerations if running with more than one substep physx_rb_api = self._get_physx_rigid_body_api(prim) if self._sim_params["substeps"] > 1: physx_rb_api.GetRetainAccelerationsAttr().Set(True) def make_kinematic(self, name, prim, cfg, value=None): # make rigid body kinematic (fixed base and no collision) from pxr import UsdPhysics, PhysxSchema stage = omni.usd.get_context().get_stage() if value is None: value = self._get_actor_config_value(name, "make_kinematic") if value: # parse through all children prims prims = [prim] while len(prims) > 0: cur_prim = prims.pop(0) rb = UsdPhysics.RigidBodyAPI.Get(stage, cur_prim.GetPath()) if rb: rb.CreateKinematicEnabledAttr().Set(True) children_prims = cur_prim.GetPrim().GetChildren() prims = prims + children_prims def set_articulation_position_iteration(self, name, prim, value=None): arti_api = self._get_physx_articulation_api(prim) solver_position_iteration_count = arti_api.GetSolverPositionIterationCountAttr() if value is None: value = self._get_actor_config_value(name, "solver_position_iteration_count", solver_position_iteration_count) if value != -1: solver_position_iteration_count.Set(value) def set_articulation_velocity_iteration(self, name, prim, value=None): arti_api = self._get_physx_articulation_api(prim) solver_velocity_iteration_count = arti_api.GetSolverVelocityIterationCountAttr() if value is None: value = self._get_actor_config_value(name, "solver_velocity_iteration_count", solver_velocity_iteration_count) if value != -1: solver_velocity_iteration_count.Set(value) def set_articulation_sleep_threshold(self, name, prim, value=None): arti_api = self._get_physx_articulation_api(prim) sleep_threshold = arti_api.GetSleepThresholdAttr() if value is None: value = self._get_actor_config_value(name, "sleep_threshold", sleep_threshold) if value != -1: sleep_threshold.Set(value) def set_articulation_stabilization_threshold(self, name, prim, value=None): arti_api = self._get_physx_articulation_api(prim) stabilization_threshold = arti_api.GetStabilizationThresholdAttr() if value is None: value = self._get_actor_config_value(name, "stabilization_threshold", stabilization_threshold) if value != -1: stabilization_threshold.Set(value) def apply_rigid_body_settings(self, name, prim, cfg, is_articulation): from pxr import UsdPhysics, PhysxSchema stage = omni.usd.get_context().get_stage() rb_api = UsdPhysics.RigidBodyAPI.Get(stage, prim.GetPath()) physx_rb_api = PhysxSchema.PhysxRigidBodyAPI.Get(stage, prim.GetPath()) if not physx_rb_api: physx_rb_api = PhysxSchema.PhysxRigidBodyAPI.Apply(prim) # if it's a body in an articulation, it's handled at articulation root if not is_articulation: self.make_kinematic(name, prim, cfg, cfg["make_kinematic"]) self.set_position_iteration(name, prim, cfg["solver_position_iteration_count"]) self.set_velocity_iteration(name, prim, cfg["solver_velocity_iteration_count"]) self.set_max_depenetration_velocity(name, prim, cfg["max_depenetration_velocity"]) self.set_sleep_threshold(name, prim, cfg["sleep_threshold"]) self.set_stabilization_threshold(name, prim, cfg["stabilization_threshold"]) self.set_gyroscopic_forces(name, prim, cfg["enable_gyroscopic_forces"]) # density and mass mass_api = UsdPhysics.MassAPI.Get(stage, prim.GetPath()) if mass_api is None: mass_api = UsdPhysics.MassAPI.Apply(prim) mass_attr = mass_api.GetMassAttr() density_attr = mass_api.GetDensityAttr() if not mass_attr: mass_attr = mass_api.CreateMassAttr() if not density_attr: density_attr = mass_api.CreateDensityAttr() if cfg["density"] != -1: density_attr.Set(cfg["density"]) mass_attr.Set(0.0) # mass is to be computed elif cfg["override_usd_defaults"] and not density_attr.IsAuthored() and not mass_attr.IsAuthored(): density_attr.Set(self._physx_params["density"]) self.retain_acceleration(prim) def apply_rigid_shape_settings(self, name, prim, cfg): from pxr import UsdPhysics, PhysxSchema stage = omni.usd.get_context().get_stage() # collision APIs collision_api = UsdPhysics.CollisionAPI(prim) if not collision_api: collision_api = UsdPhysics.CollisionAPI.Apply(prim) physx_collision_api = PhysxSchema.PhysxCollisionAPI(prim) if not physx_collision_api: physx_collision_api = PhysxSchema.PhysxCollisionAPI.Apply(prim) self.set_contact_offset(name, prim, cfg["contact_offset"]) self.set_rest_offset(name, prim, cfg["rest_offset"]) def apply_articulation_settings(self, name, prim, cfg): from pxr import UsdPhysics, PhysxSchema stage = omni.usd.get_context().get_stage() is_articulation = False # check if is articulation prims = [prim] while len(prims) > 0: prim_tmp = prims.pop(0) articulation_api = UsdPhysics.ArticulationRootAPI.Get(stage, prim_tmp.GetPath()) physx_articulation_api = PhysxSchema.PhysxArticulationAPI.Get(stage, prim_tmp.GetPath()) if articulation_api or physx_articulation_api: is_articulation = True children_prims = prim_tmp.GetPrim().GetChildren() prims = prims + children_prims # parse through all children prims prims = [prim] while len(prims) > 0: cur_prim = prims.pop(0) rb = UsdPhysics.RigidBodyAPI.Get(stage, cur_prim.GetPath()) collision_body = UsdPhysics.CollisionAPI.Get(stage, cur_prim.GetPath()) articulation = UsdPhysics.ArticulationRootAPI.Get(stage, cur_prim.GetPath()) if rb: self.apply_rigid_body_settings(name, cur_prim, cfg, is_articulation) if collision_body: self.apply_rigid_shape_settings(name, cur_prim, cfg) if articulation: articulation_api = UsdPhysics.ArticulationRootAPI.Get(stage, cur_prim.GetPath()) physx_articulation_api = PhysxSchema.PhysxArticulationAPI.Get(stage, cur_prim.GetPath()) # enable self collisions enable_self_collisions = physx_articulation_api.GetEnabledSelfCollisionsAttr() if cfg["enable_self_collisions"] != -1: enable_self_collisions.Set(cfg["enable_self_collisions"]) self.set_articulation_position_iteration(name, cur_prim, cfg["solver_position_iteration_count"]) self.set_articulation_velocity_iteration(name, cur_prim, cfg["solver_velocity_iteration_count"]) self.set_articulation_sleep_threshold(name, cur_prim, cfg["sleep_threshold"]) self.set_articulation_stabilization_threshold(name, cur_prim, cfg["stabilization_threshold"]) children_prims = cur_prim.GetPrim().GetChildren() prims = prims + children_prims
18,895
Python
44.314149
129
0.637629
makolon/hsr_isaac_tamp/hsr_rl/utils/config_utils/default_scene_params.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. default_physx_params = { ### Per-scene settings "use_gpu": False, "worker_thread_count": 4, "solver_type": 1, # 0: PGS, 1:TGS "bounce_threshold_velocity": 0.2, "friction_offset_threshold": 0.04, # A threshold of contact separation distance used to decide if a contact # point will experience friction forces. "friction_correlation_distance": 0.025, # Contact points can be merged into a single friction anchor if the # distance between the contacts is smaller than correlation distance. # disabling these can be useful for debugging "enable_sleeping": True, "enable_stabilization": True, # GPU buffers "gpu_max_rigid_contact_count": 512 * 1024, "gpu_max_rigid_patch_count": 80 * 1024, "gpu_found_lost_pairs_capacity": 1024, "gpu_found_lost_aggregate_pairs_capacity": 1024, "gpu_total_aggregate_pairs_capacity": 1024, "gpu_max_soft_body_contacts": 1024 * 1024, "gpu_max_particle_contacts": 1024 * 1024, "gpu_heap_capacity": 64 * 1024 * 1024, "gpu_temp_buffer_capacity": 16 * 1024 * 1024, "gpu_max_num_partitions": 8, ### Per-actor settings ( can override in actor_options ) "solver_position_iteration_count": 4, "solver_velocity_iteration_count": 1, "sleep_threshold": 0.0, # Mass-normalized kinetic energy threshold below which an actor may go to sleep. # Allowed range [0, max_float). "stabilization_threshold": 0.0, # Mass-normalized kinetic energy threshold below which an actor may # participate in stabilization. Allowed range [0, max_float). ### Per-body settings ( can override in actor_options ) "enable_gyroscopic_forces": False, "density": 1000.0, # density to be used for bodies that do not specify mass or density "max_depenetration_velocity": 100.0, ### Per-shape settings ( can override in actor_options ) "contact_offset": 0.02, "rest_offset": 0.001 } default_physics_material = { "static_friction": 1.0, "dynamic_friction": 1.0, "restitution": 0.0 } default_sim_params = { "gravity": [0.0, 0.0, -9.81], "dt": 1.0 / 60.0, "substeps": 1, "use_gpu_pipeline": True, "add_ground_plane": True, "add_distant_light": True, "use_flatcache": True, "enable_scene_query_support": False, "enable_cameras": False, "disable_contact_processing": False, "default_physics_material": default_physics_material } default_actor_options = { # -1 means use authored value from USD or default values from default_sim_params if not explicitly authored in USD. # If an attribute value is not explicitly authored in USD, add one with the value given here, # which overrides the USD default. "override_usd_defaults": False, "make_kinematic": -1, "enable_self_collisions": -1, "enable_gyroscopic_forces": -1, "solver_position_iteration_count": -1, "solver_velocity_iteration_count": -1, "sleep_threshold": -1, "stabilization_threshold": -1, "max_depenetration_velocity": -1, "density": -1, "mass": -1, "contact_offset": -1, "rest_offset": -1 }
4,801
Python
41.875
119
0.684649
makolon/hsr_isaac_tamp/hsr_rl/utils/config_utils/path_utils.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 from hydra.utils import to_absolute_path import os def is_valid_local_file(path): return os.path.isfile(path) def is_valid_ov_file(path): import omni.client result, entry = omni.client.stat(path) return result == omni.client.Result.OK def download_ov_file(source_path, target_path): import omni.client result = omni.client.copy(source_path, target_path) if result == omni.client.Result.OK: return True return False def break_ov_path(path): import omni.client return omni.client.break_url(path) def retrieve_checkpoint_path(path): # check if it's a local path if is_valid_local_file(path): return to_absolute_path(path) # check if it's an OV path elif is_valid_ov_file(path): ov_path = break_ov_path(path) file_name = os.path.basename(ov_path.path) target_path = f"checkpoints/{file_name}" copy_to_local = download_ov_file(path, target_path) return to_absolute_path(target_path) else: carb.log_error(f"Invalid checkpoint path: {path}") return None
2,656
Python
38.656716
80
0.735693
makolon/hsr_isaac_tamp/hsr_rl/utils/hydra_cfg/hydra_utils.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 hydra from omegaconf import DictConfig, OmegaConf ## OmegaConf & Hydra Config # Resolvers used in hydra configs (see https://omegaconf.readthedocs.io/en/2.1_branch/usage.html#resolvers) OmegaConf.register_new_resolver('eq', lambda x, y: x.lower()==y.lower()) OmegaConf.register_new_resolver('contains', lambda x, y: x.lower() in y.lower()) OmegaConf.register_new_resolver('if', lambda pred, a, b: a if pred else b) # allows us to resolve default arguments which are copied in multiple places in the config. used primarily for # num_ensv OmegaConf.register_new_resolver('resolve_default', lambda default, arg: default if arg=='' else arg)
2,206
Python
52.829267
110
0.776065
makolon/hsr_isaac_tamp/hsr_rl/utils/hydra_cfg/reformat.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 omegaconf import DictConfig, OmegaConf from typing import Dict def omegaconf_to_dict(d: DictConfig)->Dict: """Converts an omegaconf DictConfig to a python Dict, respecting variable interpolation.""" ret = {} for k, v in d.items(): if isinstance(v, DictConfig): ret[k] = omegaconf_to_dict(v) else: ret[k] = v return ret def print_dict(val, nesting: int = -4, start: bool = True): """Outputs a nested dictionory.""" 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: print(val)
2,307
Python
41.74074
95
0.70958
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_assets.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 omni.usd import omni.client from pxr import UsdGeom, Sdf def update_reference(source_prim_path, source_reference_path, target_reference_path): stage = omni.usd.get_context().get_stage() prims = [stage.GetPrimAtPath(source_prim_path)] while len(prims) > 0: prim = prims.pop(0) prim_spec = stage.GetRootLayer().GetPrimAtPath(prim.GetPath()) reference_list = prim_spec.referenceList refs = reference_list.GetAddedOrExplicitItems() if len(refs) > 0: for ref in refs: if ref.assetPath == source_reference_path: prim.GetReferences().RemoveReference(ref) prim.GetReferences().AddReference(assetPath=target_reference_path, primPath=prim.GetPath()) prims = prims + prim.GetChildren() def create_parent_xforms(asset_usd_path, source_prim_path, save_as_path=None): """ Adds a new UsdGeom.Xform prim for each Mesh/Geometry prim under source_prim_path. Moves material assignment to new parent prim if any exists on the Mesh/Geometry prim. Args: asset_usd_path (str): USD file path for asset source_prim_path (str): USD path of root prim save_as_path (str): USD file path for modified USD stage. Defaults to None, will save in same file. """ omni.usd.get_context().open_stage(asset_usd_path) stage = omni.usd.get_context().get_stage() prims = [stage.GetPrimAtPath(source_prim_path)] edits = Sdf.BatchNamespaceEdit() while len(prims) > 0: prim = prims.pop(0) print(prim) if prim.GetTypeName() in ["Mesh", "Capsule", "Sphere", "Box"]: new_xform = UsdGeom.Xform.Define(stage, str(prim.GetPath()) + "_xform") print(prim, new_xform) edits.Add(Sdf.NamespaceEdit.Reparent(prim.GetPath(), new_xform.GetPath(), 0)) continue children_prims = prim.GetChildren() prims = prims + children_prims stage.GetRootLayer().Apply(edits) if save_as_path is None: omni.usd.get_context().save_stage() else: omni.usd.get_context().save_as_stage(save_as_path) def convert_asset_instanceable(asset_usd_path, source_prim_path, save_as_path=None, create_xforms=True): """ Makes all mesh/geometry prims instanceable. Can optionally add UsdGeom.Xform prim as parent for all mesh/geometry prims. Makes a copy of the asset USD file, which will be used for referencing. Updates asset file to convert all parent prims of mesh/geometry prims to reference cloned USD file. Args: asset_usd_path (str): USD file path for asset source_prim_path (str): USD path of root prim save_as_path (str): USD file path for modified USD stage. Defaults to None, will save in same file. create_xforms (bool): Whether to add new UsdGeom.Xform prims to mesh/geometry prims. """ if create_xforms: create_parent_xforms(asset_usd_path, source_prim_path, save_as_path) asset_usd_path = save_as_path instance_usd_path = ".".join(asset_usd_path.split(".")[:-1]) + "_meshes.usd" omni.client.copy(asset_usd_path, instance_usd_path) omni.usd.get_context().open_stage(asset_usd_path) stage = omni.usd.get_context().get_stage() prims = [stage.GetPrimAtPath(source_prim_path)] while len(prims) > 0: prim = prims.pop(0) if prim: if prim.GetTypeName() in ["Mesh", "Capsule", "Sphere", "Box"]: parent_prim = prim.GetParent() if parent_prim and not parent_prim.IsInstance(): parent_prim.GetReferences().AddReference(assetPath=instance_usd_path, primPath=str(parent_prim.GetPath())) parent_prim.SetInstanceable(True) continue children_prims = prim.GetChildren() prims = prims + children_prims if save_as_path is None: omni.usd.get_context().save_stage() else: omni.usd.get_context().save_as_stage(save_as_path)
5,638
Python
44.112
126
0.675949
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/utils/usd_utils/ov_utils.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 omni.client def is_valid_ov_file(path): result, entry = omni.client.stat(path) return result == omni.client.Result.OK def download_ov_file(source_path, target_path): result = omni.client.copy(source_path, target_path) if result == omni.client.Result.OK: return True return False def break_ov_path(path): return omni.client.break_url(path)
1,917
Python
42.590908
80
0.775691
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/cabinet.py
# Copyright (c) 2021, 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 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.stage import add_reference_to_stage from hsr_rl.utils.files import get_usd_path import numpy as np import torch import carb class Cabinet(Robot): def __init__( self, prim_path: str, name: Optional[str] = "cabinet", usd_path: Optional[str] = None, translation: Optional[torch.tensor] = None, orientation: Optional[torch.tensor] = None, ) -> None: """[summary] """ self._usd_path = usd_path self._name = name if self._usd_path is None: assets_root_path = get_assets_root_path() if assets_root_path is None: carb.log_error("Could not find Isaac Sim assets folder") self._usd_path = (get_usd_path() / 'Props' / 'Sektion_Cabinet' / 'sektion_cabinet_instanceable.usd').as_posix() add_reference_to_stage(self._usd_path, prim_path) self._position = torch.tensor([0.0, 0.0, 0.4]) if translation is None else translation self._orientation = torch.tensor([0.1, 0.0, 0.0, 0.0]) if orientation is None else orientation super().__init__( prim_path=prim_path, name=name, translation=self._position, orientation=self._orientation, articulation_controller=None, )
1,896
Python
34.792452
123
0.656646
makolon/hsr_isaac_tamp/hsr_rl/robots/articulations/views/cabinet_view.py
from typing import Optional from omni.isaac.core.articulations import ArticulationView from omni.isaac.core.prims import RigidPrimView class CabinetView(ArticulationView): def __init__( self, prim_paths_expr: str, name: Optional[str] = "CabinetView", ) -> None: """[summary] """ super().__init__( prim_paths_expr=prim_paths_expr, name=name, reset_xform_properties=False ) self._drawers = RigidPrimView(prim_paths_expr="/World/envs/.*/cabinet/drawer_top", name="drawers_view", reset_xform_properties=False)
618
Python
27.136362
141
0.619741
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_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/docker/docker_openrave/ros_package/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/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/CHANGELOG.rst
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package hsrb_description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.0.0 (2020-08-24) ------------------- * Initial commit * Contributors: Nobuyuki Matsuno, Takashi Yamamoto, Yasukata Yokochi, Yuka Hashiguchi
260
reStructuredText
27.999997
85
0.496154
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="[email protected]">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="[email protected]">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 <[email protected]> // // 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/create_dataset.py
#!/usr/bin/env python import threading 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 create_dataset, create_skill_dataset, \ # 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=True, 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=bool, default=True) parser.add_argument("--debug", help="save visualization", type=bool, default=False) parser.add_argument("--skill", action='store_true', help="select skill dataset") 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 target_object_name = None 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) target_object_name = problem.body_names[b] 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) target_object_name = problem.body_names[b1] 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) target_object_name = problem.body_names[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 += ((name, target_object_name, 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, max_time=60, max_iterations=4, max_complexity=4, verbose=True, debug=False) saver.restore() print_solution(solution) plan, cost, evaluations = solution print('#############################') print('plan: ', plan) print('#############################') if (plan is None): disconnect() return with LockRenderer(lock=not args.enable): commands = self.post_process(tamp_problem, plan) tamp_problem.remove_gripper() saver.restore() if args.problem == 'gearbox_problem': print("Create Dataset!") if args.skill: create_skill_dataset(args.problem, tamp_problem.robot, tamp_problem.bodies, tamp_problem.body_names, State(), commands, time_step=0.01) else: create_dataset(args.problem, tamp_problem.robot, tamp_problem.bodies, tamp_problem.body_names, State(), commands, time_step=0.01) else: print("Create Dataset!") if args.skill: create_skill_dataset(args.problem, tamp_problem.robot, tamp_problem.bodies, tamp_problem.body_names, State(), commands, time_step=0.01) else: create_dataset(args.problem, tamp_problem.robot, tamp_problem.bodies, tamp_problem.body_names, State(), commands, time_step=0.01) disconnect() return def main_loop(): tamp_planner = TAMPPlanner() tamp_planner.plan() if __name__ == '__main__': main_loop()
13,785
Python
42.765079
151
0.584186
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/tamp_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_named_commands, control_commands, replay_trajectory, \ # 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, ####################################################### def select_plan(plan, movable): import itertools predefined_order = list(itertools.permutations(movable)) filtered_permutations = [p for p in predefined_order if p.index(6) < p.index(3)] filtered_permutations = [p for p in filtered_permutations if p.index(7) < p.index(4)] filtered_permutations = [p for p in filtered_permutations if p.index(5) < p.index(4)] object_order = [] for i, (name, args) in enumerate(plan): if name == 'insert': _, b1, b2, _, _, _, _, _, _ = args object_order.append(b1) else: pass object_order = tuple(object_order) if object_order in filtered_permutations: executable = True else: executable = False return True # executable ####################################################### class TAMPPlanner(object): def parse_observation(self, object_names, object_poses, body): object_name = object_names[body] object_pose = object_poses[object_name] object_offset = {'shaft1': 0.015, 'shaft2': 0.015, 'gear1': 0.025, 'gear2': 0.025, 'gear3': 0.025} # grasp offset 0.025 from marker position rigid_pose = ((object_pose[0][0], object_pose[0][1], object_pose[0][2]-object_offset[object_name]), (0.0, 0.0, 0.0, 1.0)) return rigid_pose def pddlstream_from_problem(self, problem, observations, 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 = {} robot_pose, object_pose = observations base_conf = robot_pose[:3] # base_footprint configuration assert len(base_conf) == 3, "Does not match the size of the base_conf" initial_bq = Conf(robot, get_group_joints(robot, 'base'), base_conf) 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') arm_conf = robot_pose[3:] # arm configuration assert len(arm_conf) == 5, "Does not match the size of arm_conf" conf = Conf(robot, joints, arm_conf) init += [('Arm', 'arm'), ('AConf', 'arm', conf), ('HandEmpty', 'arm'), ('AtAConf', 'arm', conf)] init += [('Controllable', 'arm')] for body in problem.movable: body_pose = self.parse_observation(problem.body_names, object_pose, body) pose = Pose(body, body_pose) 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, objservations): 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') 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('-n', '--number', default=4, type=int, help='The number of blocks') parser.add_argument('-p', '--problem', default='real_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("--cfree", help="select collision activate", type=bool, 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(objservations) self.pddlstream_problem = self.pddlstream_from_problem(tamp_problem, objservations, collisions=not args.cfree, teleport=args.teleport) self.tamp_problem = tamp_problem self.args = 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 target_object_name = None new_commands = c.commands elif name == 'pick': a, b, p, g, _, c = args [traj_pick] = c.commands close_gripper = GripperCommand(problem.robot, a, g.grasp_width, teleport=teleport) attach = Attach(problem.robot, a, g, b) target_object_name = problem.body_names[b] new_commands = [traj_pick, close_gripper, attach, traj_pick.reverse()] elif name == 'place': a, b1, b2, p, g, _, c = args [traj_place] = c.commands gripper_joint = get_gripper_joints(problem.robot, a)[0] position = get_max_limit(problem.robot, gripper_joint) target_object_name = problem.body_names[b1] new_commands = [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) target_object_name = problem.body_names[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 += ((name, target_object_name, new_commands),) return commands def plan(self): saver = WorldSaver() 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 = self.pddlstream_problem print('Init:', init) print('Goal:', goal) print('Streams:', str_from_object(set(stream_map))) print(SEPARATOR) with Profiler(): with LockRenderer(lock=not self.args.enable): solution = solve(self.pddlstream_problem, algorithm=self.args.algorithm, unit_costs=self.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 if not select_plan(plan, self.tamp_problem.movable): print("Cannot execute plan") return return plan, cost, evaluations def execute(self, plan, execute=False): saver = WorldSaver() if (plan is None) or not has_gui(): return commands = self.post_process(self.tamp_problem, plan) self.tamp_problem.remove_gripper() saver.restore() if execute: wait_if_gui('Execute?') apply_named_commands(State(), commands, time_step=0.03) wait_if_gui('Finish?') pick_metadata, place_metadata, insert_metadata = replay_trajectory(self.tamp_problem.robot, self.tamp_problem.bodies, self.tamp_problem.body_names, State(), commands) disconnect() return pick_metadata, place_metadata, insert_metadata if __name__ == '__main__': tamp_planner = TAMPPlanner() plan = tamp_planner.plan() tamp_planner.execute(plan)
15,151
Python
41.088889
174
0.582998
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. <!--![Alt text](images/test.png?raw=true "Title")--> <!--img src="images/pr2.png" height="300">&emsp;<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 [email protected]: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">&emsp;<img src="images/turtlebot_motion.png" height="150"> &emsp;<img src="images/pr2_motion.png" height="150"> <img src="images/franka.png" height="150">&emsp;<img src="images/movo2.png" height="150"> &emsp;<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">&emsp;<img src="images/tamp_xml.png" height="150"> &emsp;<img src="images/water.png" height="150"> <!--&emsp;<img src="images/test_side.png" height="150"> &emsp;<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
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/smoothing.py
from random import randint, random from .utils import INF, elapsed_time, irange, waypoints_from_path, get_pairs, get_distance, \ convex_combination, flatten, traverse, compute_path_cost import time import numpy as np def smooth_path_old(path, extend, collision, iterations=50, max_time=INF, verbose=False, **kwargs): assert (iterations < INF) or (max_time < INF) start_time = time.time() smoothed_path = path for iteration in irange(iterations): if (elapsed_time(start_time) > max_time) or (len(smoothed_path) <= 2): break if verbose: print('Iteration: {} | Waypoints: {} | Euclidean distance: {:.3f} | Time: {:.3f}'.format( iteration, len(smoothed_path), compute_path_cost(smoothed_path), elapsed_time(start_time))) i = randint(0, len(smoothed_path) - 1) j = randint(0, len(smoothed_path) - 1) if abs(i - j) <= 1: continue if j < i: i, j = j, i shortcut = list(extend(smoothed_path[i], smoothed_path[j])) if (len(shortcut) < (j - i)) and all(not collision(q) for q in traverse(shortcut)): smoothed_path = smoothed_path[:i + 1] + shortcut + smoothed_path[j + 1:] return smoothed_path def refine_waypoints(waypoints, extend_fn): #if len(waypoints) <= 1: # return waypoints return list(flatten(extend_fn(q1, q2) for q1, q2 in get_pairs(waypoints))) # [waypoints[0]] + def smooth_path(path, extend, collision, distance_fn=None, iterations=50, max_time=INF, verbose=False): # TODO: makes an assumption on the distance metric # TODO: smooth until convergence assert (iterations < INF) or (max_time < INF) start_time = time.time() if distance_fn is None: distance_fn = get_distance waypoints = waypoints_from_path(path) for iteration in irange(iterations): #waypoints = waypoints_from_path(waypoints) if (elapsed_time(start_time) > max_time) or (len(waypoints) <= 2): break # TODO: smoothing in the same linear segment when circular indices = list(range(len(waypoints))) segments = list(get_pairs(indices)) distances = [distance_fn(waypoints[i], waypoints[j]) for i, j in segments] total_distance = sum(distances) if verbose: print('Iteration: {} | Waypoints: {} | Distance: {:.3f} | Time: {:.3f}'.format( iteration, len(waypoints), total_distance, elapsed_time(start_time))) probabilities = np.array(distances) / total_distance #segment1, segment2 = choices(segments, weights=probabilities, k=2) seg_indices = list(range(len(segments))) seg_idx1, seg_idx2 = np.random.choice(seg_indices, size=2, replace=True, p=probabilities) if seg_idx1 == seg_idx2: continue if seg_idx2 < seg_idx1: # choices samples with replacement seg_idx1, seg_idx2 = seg_idx2, seg_idx1 segment1, segment2 = segments[seg_idx1], segments[seg_idx2] # TODO: option to sample only adjacent pairs point1, point2 = [convex_combination(waypoints[i], waypoints[j], w=random()) for i, j in [segment1, segment2]] i, _ = segment1 _, j = segment2 new_waypoints = waypoints[:i+1] + [point1, point2] + waypoints[j:] # TODO: reuse computation if compute_path_cost(new_waypoints, cost_fn=distance_fn) >= total_distance: continue if all(not collision(q) for q in traverse(extend(point1, point2))): waypoints = new_waypoints #return waypoints return refine_waypoints(waypoints, extend) #smooth_path = smooth_path_old
3,687
Python
45.683544
107
0.625712
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/graph.py
from collections import namedtuple, Mapping from heapq import heappush, heappop class Vertex(object): def __init__(self, value): self.value = value self.edges = [] def __repr__(self): return self.__class__.__name__ + '(' + str(self.value) + ')' class Edge(object): def __init__(self, v1, v2, value, cost): self.v1, self.v2 = v1, v2 self.v1.edges.append(self) self.value = value self.cost = cost def __repr__(self): return self.__class__.__name__ + '(' + str(self.v1.value) + ' -> ' + str(self.v2.value) + ')' SearchNode = namedtuple('SearchNode', ['cost', 'edge']) class Graph(Mapping, object): def __init__(self): self.vertices = {} self.edges = [] def __getitem__(self, value): return self.vertices[value] def __len__(self): return len(self.vertices) def __iter__(self): return iter(self.vertices) def __call__(self, value1, value2): # TODO - goal_test if value1 not in self or value2 not in self: return None start, goal = self[value1], self[value2] queue = [(0, start)] nodes, processed = {start: SearchNode(0, None)}, set() def retrace(v): edge = nodes[v].edge if edge is None: return [v.value], [] vertices, edges = retrace(edge.v1) return vertices + [v.value], edges + [edge.value] while len(queue) != 0: _, cv = heappop(queue) if cv in processed: continue processed.add(cv) if cv == goal: return retrace(cv) for edge in cv.edges: cost = nodes[cv].cost + edge.cost if edge.v2 not in nodes or cost < nodes[edge.v2].cost: nodes[edge.v2] = SearchNode(cost, edge) heappush(queue, (cost, edge.v2)) return None def add(self, value): if value not in self: self.vertices[value] = Vertex(value) return self.vertices[value] def connect(self, value1, value2, edge_value=None, edge_cost=1): v1, v2 = self.add(value1), self.add(value2) edge = Edge(v1, v2, edge_value, edge_cost) self.edges.append(edge) return edge
2,335
Python
27.144578
101
0.529336
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/rrt_star.py
from __future__ import print_function from random import random from time import time from .utils import INF, argmin, elapsed_time class OptimalNode(object): def __init__(self, config, parent=None, d=0, path=[], iteration=None): self.config = config self.parent = parent self.children = set() self.d = d self.path = path if parent is not None: self.cost = parent.cost + d self.parent.children.add(self) else: self.cost = d self.solution = False self.creation = iteration self.last_rewire = iteration def set_solution(self, solution): if self.solution is solution: return self.solution = solution if self.parent is not None: self.parent.set_solution(solution) def retrace(self): if self.parent is None: return self.path + [self.config] return self.parent.retrace() + self.path + [self.config] def rewire(self, parent, d, path, iteration=None): if self.solution: self.parent.set_solution(False) self.parent.children.remove(self) self.parent = parent self.parent.children.add(self) if self.solution: self.parent.set_solution(True) self.d = d self.path = path self.update() self.last_rewire = iteration def update(self): self.cost = self.parent.cost + self.d for n in self.children: n.update() def clear(self): self.node_handle = None self.edge_handle = None def draw(self, env): from manipulation.primitives.display import draw_node, draw_edge color = (0, 0, 1, .5) if self.solution else (1, 0, 0, .5) 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 self.__class__.__name__ + '(' + str(self.config) + ')' __repr__ = __str__ def safe_path(sequence, collision): path = [] for q in sequence: if collision(q): break path.append(q) return path def rrt_star(start, goal, distance, sample, extend, collision, radius, max_time=INF, max_iterations=INF, goal_probability=.2, informed=True): if collision(start) or collision(goal): return None nodes = [OptimalNode(start)] goal_n = None t0 = time() it = 0 while (t0 - time()) < max_time and it < max_iterations: do_goal = goal_n is None and (it == 0 or random() < goal_probability) s = goal if do_goal else sample() # Informed RRT* if informed and goal_n is not None and distance(start, s) + distance(s, goal) >= goal_n.cost: continue if it % 100 == 0: success = goal_n is not None cost = goal_n.cost if success else INF print(it, elapsed_time(t0), success, do_goal, cost) it += 1 nearest = argmin(lambda n: distance(n.config, s), nodes) path = safe_path(extend(nearest.config, s), collision) if len(path) == 0: continue new = OptimalNode(path[-1], parent=nearest, d=distance( nearest.config, path[-1]), path=path[:-1], iteration=it) # if safe and do_goal: if do_goal and distance(new.config, goal) < 1e-6: goal_n = new goal_n.set_solution(True) # TODO - k-nearest neighbor version neighbors = filter(lambda n: distance( n.config, new.config) < radius, nodes) nodes.append(new) for n in neighbors: d = distance(n.config, new.config) if n.cost + d < new.cost: path = safe_path(extend(n.config, new.config), collision) if len(path) != 0 and distance(new.config, path[-1]) < 1e-6: new.rewire(n, d, path[:-1], iteration=it) for n in neighbors: # TODO - avoid repeating work d = distance(new.config, n.config) if new.cost + d < n.cost: path = safe_path(extend(new.config, n.config), collision) if len(path) != 0 and distance(n.config, path[-1]) < 1e-6: n.rewire(new, d, path[:-1], iteration=it) if goal_n is None: return None return goal_n.retrace()
4,467
Python
33.10687
141
0.564585
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/tkinter/viewer.py
try: from Tkinter import Tk, Canvas, Toplevel, LAST #import TKinter as tk except ModuleNotFoundError: from tkinter import Tk, Canvas, Toplevel, LAST #import tkinter as tk import numpy as np from collections import namedtuple from ..utils import get_pairs, get_delta, INF Box = namedtuple('Box', ['lower', 'upper']) Circle = namedtuple('Circle', ['center', 'radius']) class PRMViewer(object): def __init__(self, width=500, height=500, title='PRM', background='tan'): tk = Tk() tk.withdraw() top = Toplevel(tk) top.wm_title(title) top.protocol('WM_DELETE_WINDOW', top.destroy) self.width = width self.height = height self.canvas = Canvas(top, width=self.width, height=self.height, background=background) self.canvas.pack() def pixel_from_point(self, point): (x, y) = point # return (int(x*self.width), int(self.height - y*self.height)) return (x * self.width, self.height - y * self.height) def draw_point(self, point, radius=5, color='black'): (x, y) = self.pixel_from_point(point) self.canvas.create_oval(x - radius, y - radius, x + radius, y + radius, fill=color, outline='') def draw_line(self, segment, color='black'): (point1, point2) = segment (x1, y1) = self.pixel_from_point(point1) (x2, y2) = self.pixel_from_point(point2) self.canvas.create_line(x1, y1, x2, y2, fill=color, width=1) def draw_arrow(self, point1, point2, color='black'): (x1, y1) = self.pixel_from_point(point1) (x2, y2) = self.pixel_from_point(point2) self.canvas.create_line(x1, y1, x2, y2, fill=color, width=2, arrow=LAST) def draw_rectangle(self, box, width=2, color='brown'): (point1, point2) = box (x1, y1) = self.pixel_from_point(point1) (x2, y2) = self.pixel_from_point(point2) self.canvas.create_rectangle(x1, y1, x2, y2, fill=color, width=width) def draw_circle(self, center, radius, width=2, color='black'): (x1, y1) = self.pixel_from_point(np.array(center) - radius * np.ones(2)) (x2, y2) = self.pixel_from_point(np.array(center) + radius * np.ones(2)) self.canvas.create_oval(x1, y1, x2, y2, outline='black', fill=color, width=width) def clear(self): self.canvas.delete('all') ################################################################# def contains(q, box): (lower, upper) = box return np.greater_equal(q, lower).all() and \ np.greater_equal(upper, q).all() #return np.all(q >= lower) and np.all(upper >= q) def point_collides(point, boxes): return any(contains(point, box) for box in boxes) def sample_line(segment, step_size=2e-2): (q1, q2) = segment diff = get_delta(q1, q2) dist = np.linalg.norm(diff) for l in np.arange(0., dist, step_size): yield tuple(np.array(q1) + l * diff / dist) yield q2 def line_collides(line, box): # TODO - could also compute this exactly return any(point_collides(point, boxes=[box]) for point in sample_line(line)) def is_collision_free(line, boxes): return not any(line_collides(line, box) for box in boxes) def create_box(center, extents): (x, y) = center (w, h) = extents lower = (x - w / 2., y - h / 2.) upper = (x + w / 2., y + h / 2.) return Box(np.array(lower), np.array(upper)) def get_box_center(box): lower, upper = box return np.average([lower, upper], axis=0) def get_box_extent(box): lower, upper = box return get_delta(lower, upper) def sample_box(box): (lower, upper) = box return np.random.random(len(lower)) * get_box_extent(box) + lower ################################################################# def draw_environment(obstacles, regions): viewer = PRMViewer() for box in obstacles: viewer.draw_rectangle(box, color='brown') for name, region in regions.items(): if name != 'env': viewer.draw_rectangle(region, color='green') return viewer def add_segments(viewer, segments, step_size=INF, **kwargs): if segments is None: return for line in segments: viewer.draw_line(line, **kwargs) #for p in [p1, p2]: for p in sample_line(line, step_size=step_size): viewer.draw_point(p, radius=2, **kwargs) def add_path(viewer, path, **kwargs): segments = list(get_pairs(path)) return add_segments(viewer, segments, **kwargs) def draw_solution(segments, obstacles, regions): viewer = draw_environment(obstacles, regions) add_segments(viewer, segments) def add_roadmap(viewer, roadmap, **kwargs): for line in roadmap: viewer.draw_line(line, **kwargs) def draw_roadmap(roadmap, obstacles, regions): viewer = draw_environment(obstacles, regions) add_roadmap(viewer, roadmap) def add_points(viewer, points, **kwargs): for sample in points: viewer.draw_point(sample, **kwargs) def get_distance_fn(weights): difference_fn = get_delta def fn(q1, q2): diff = np.array(difference_fn(q2, q1)) return np.sqrt(np.dot(weights, diff * diff)) return fn
5,167
Python
32.558441
103
0.613122
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/motion/motion_planners/tkinter/run.py
from __future__ import print_function import numpy as np import math from .viewer import sample_box, is_collision_free, \ create_box, draw_environment, point_collides, sample_line, add_points, \ add_roadmap, get_box_center, add_path, get_distance_fn from ..utils import user_input, profiler, INF, compute_path_cost, get_distance from ..rrt_connect import rrt_connect from ..meta import random_restarts from ..diverse import score_portfolio, exhaustively_select_portfolio ################################################## def get_sample_fn(region, obstacles=[]): samples = [] collision_fn = get_collision_fn(obstacles) def region_gen(): #lower, upper = region #area = np.product(upper - lower) # TODO: sample proportional to area while True: q = sample_box(region) if collision_fn(q): continue samples.append(q) return q # TODO: sampling with state (e.g. deterministic sampling) return region_gen, samples def get_connected_test(obstacles, max_distance=0.25): # 0.25 | 0.2 | 0.25 | 0.5 | 1.0 roadmap = [] def connected_test(q1, q2): #n = len(samples) #threshold = gamma * (math.log(n) / n) ** (1. / d) threshold = max_distance are_connected = (get_distance(q1, q2) <= threshold) and is_collision_free((q1, q2), obstacles) if are_connected: roadmap.append((q1, q2)) return are_connected return connected_test, roadmap def get_threshold_fn(): # http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.419.5503&rep=rep1&type=pdf d = 2 vol_free = (1 - 0) * (1 - 0) vol_ball = math.pi * (1 ** 2) gamma = 2 * ((1 + 1. / d) * (vol_free / vol_ball)) ** (1. / d) threshold_fn = lambda n: gamma * (math.log(n) / n) ** (1. / d) return threshold_fn def get_collision_fn(obstacles): def collision_fn(q): #time.sleep(1e-3) return point_collides(q, obstacles) return collision_fn def get_extend_fn(obstacles=[]): #collision_fn = get_collision_fn(obstacles) roadmap = [] def extend_fn(q1, q2): path = [q1] for q in sample_line(segment=(q1, q2)): #if collision_fn(q): # return yield q roadmap.append((path[-1], q)) path.append(q) return extend_fn, roadmap ################################################## def main(smooth=True, num_restarts=1, max_time=0.1): """ Creates and solves the 2D motion planning problem. """ # https://github.com/caelan/pddlstream/blob/master/examples/motion/run.py # TODO: 3D work and CSpace # TODO: visualize just the tool frame of an end effector np.set_printoptions(precision=3) obstacles = [ create_box(center=(.35, .75), extents=(.25, .25)), create_box(center=(.75, .35), extents=(.225, .225)), create_box(center=(.5, .5), extents=(.225, .225)), ] # TODO: alternate sampling from a mix of regions regions = { 'env': create_box(center=(.5, .5), extents=(1., 1.)), 'green': create_box(center=(.8, .8), extents=(.1, .1)), } start = np.array([0., 0.]) goal = 'green' if isinstance(goal, str) and (goal in regions): goal = get_box_center(regions[goal]) else: goal = np.array([1., 1.]) viewer = draw_environment(obstacles, regions) ######################### #connected_test, roadmap = get_connected_test(obstacles) collision_fn = get_collision_fn(obstacles) distance_fn = get_distance_fn(weights=[1, 1]) # distance_fn # samples = list(islice(region_gen('env'), 100)) with profiler(field='cumtime'): # cumtime | tottime # TODO: cost bound & best cost for _ in range(num_restarts): sample_fn, samples = get_sample_fn(regions['env']) extend_fn, roadmap = get_extend_fn(obstacles=obstacles) # obstacles | [] #path = rrt_connect(start, goal, distance_fn, sample_fn, extend_fn, collision_fn, # iterations=100, tree_frequency=1, max_time=1) #, **kwargs) #path = birrt(start, goal, distance=distance_fn, sample=sample_fn, # extend=extend_fn, collision=collision_fn, smooth=100) #, smooth=1000, **kwargs) paths = random_restarts(rrt_connect, start, goal, distance_fn=distance_fn, sample_fn=sample_fn, extend_fn=extend_fn, collision_fn=collision_fn, restarts=INF, max_time=2, max_solutions=INF, smooth=100) #, smooth=1000, **kwargs) #path = paths[0] if paths else None #if path is None: # continue #paths = [path] #paths = exhaustively_select_portfolio(paths, k=2) #print(score_portfolio(paths)) for path in paths: print('Distance: {:.3f}'.format(compute_path_cost(path, distance_fn))) add_path(viewer, path, color='green') # extend_fn, _ = get_extend_fn(obstacles=obstacles) # obstacles | [] # smoothed = smooth_path(path, extend_fn, collision_fn, iterations=INF, max_tine=max_time) # print('Smoothed distance: {:.3f}'.format(compute_path_cost(smoothed, distance_fn))) # add_path(viewer, smoothed, color='red') ######################### roadmap = samples = [] add_roadmap(viewer, roadmap, color='black') add_points(viewer, samples, color='blue') #if path is None: # user_input('Finish?') # return user_input('Finish?') if __name__ == '__main__': main()
5,682
Python
34.080247
107
0.569342
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/teleop_pr2.py
#!/usr/bin/env python from __future__ import print_function import select import sys import termios import tty from pybullet_tools.pr2_utils import PR2_GROUPS, DRAKE_PR2_URDF from pybullet_tools.utils import add_data_path, connect, enable_gravity, load_model, \ joints_from_names, load_pybullet, \ velocity_control_joints, disconnect, enable_real_time, HideOutput HELP_MSG = """ Reading from the keyboard and Publishing to Twist! --------------------------- Moving around: u i o j k l m , . For Holonomic mode (strafing), hold down the shift key: --------------------------- U I O J K L M < > t : up (+z) b : down (-z) anything else : stop q/z : increase/decrease max speeds by 10% w/x : increase/decrease only linear speed by 10% e/c : increase/decrease only angular speed by 10% CTRL-C to quit """ MOVE_BINDINGS = { 'i': (1, 0, 0, 0), 'o': (1, 0, 0, -1), 'j': (0, 0, 0, 1), 'l': (0, 0, 0, -1), 'u': (1, 0, 0, 1), ',': (-1, 0, 0, 0), '.': (-1, 0, 0, 1), 'm': (-1, 0, 0, -1), 'O': (1, -1, 0, 0), 'I': (1, 0, 0, 0), 'J': (0, 1, 0, 0), 'L': (0, -1, 0, 0), 'U': (1, 1, 0, 0), '<': (-1, 0, 0, 0), '>': (-1, -1, 0, 0), 'M': (-1, 1, 0, 0), 't': (0, 0, 1, 0), 'b': (0, 0, -1, 0), } SPEED_BINDINGS = { 'q': (1.1, 1.1), 'z': (.9, .9), 'w': (1.1, 1), 'x': (.9, 1), 'e': (1, 1.1), 'c': (1, .9), } ESCAPE = '\x03' ##################################### def get_key(settings): tty.setraw(sys.stdin.fileno()) select.select([sys.stdin], [], [], 0) key = sys.stdin.read(1) termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings) return key def print_velocities(speed, turn): print("Speed: {} | Turn: {} ".format(speed, turn)) ##################################### def run_simulate(pr2): joints = joints_from_names(pr2, PR2_GROUPS['base']) dx = dy = dz = dth = 1 speed, turn = 0.5, 1.0 while True: velocities = [dx * speed, dy * speed, dth * turn] velocity_control_joints(pr2, joints, velocities) def run_thread(pr2): joints = joints_from_names(pr2, PR2_GROUPS['base']) dx = dy = dz = dth = 0 speed, turn = 0.5, 1.0 settings = termios.tcgetattr(sys.stdin) try: print(HELP_MSG) print_velocities(speed, turn) while True: # TODO: getKeyboardEvents key = get_key(settings) # Waits until a key is read if key in MOVE_BINDINGS: dx, dy, dz, dth = MOVE_BINDINGS[key] elif key in SPEED_BINDINGS: mspeed, mturn = SPEED_BINDINGS[key] speed *= mspeed turn *= mturn print_velocities(speed, turn) else: # When it receives another key dx = dy = dz = dth = 0 if key == ESCAPE: break # twist.linear.dz = dz * speed velocities = [dx * speed, dy * speed, dth * turn] velocity_control_joints(pr2, joints, velocities) except Exception as e: print(e) finally: termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings) ##################################### def main(): # https://github.com/ros-teleop/teleop_twist_keyboard # http://openrave.org/docs/latest_stable/_modules/openravepy/misc/#SetViewerUserThread connect(use_gui=True) add_data_path() load_pybullet("plane.urdf") #load_pybullet("models/table_collision/table.urdf") with HideOutput(): pr2 = load_model(DRAKE_PR2_URDF, fixed_base=True) enable_gravity() enable_real_time() # TODO: won't work as well on OS X due to simulation thread #run_simulate(pr2) run_thread(pr2) # TODO: keep working on this #userthread = threading.Thread(target=run_thread, args=[pr2]) #userthread.start() #userthread.join() disconnect() if __name__=="__main__": main()
3,571
Python
23.465753
87
0.58555
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_kinbody.py
#!/usr/bin/env python from __future__ import print_function from lxml import etree # pip install lxml import os def find_insensitive(elem, pattern): result1 = elem.find(pattern) if result1 is not None: return result1 return elem.find(pattern.lower()) # https://github.mit.edu/mtoussai/KOMO-stream/blob/master/01-basicKOMOinTheKitchen/env2rai.py # https://github.mit.edu/mtoussai/KOMO-stream/blob/master/01-basicKOMOinTheKitchen/collada2rai.py # http://openrave.programmingvision.com/wiki/index.php/Format:XML # http://wiki.ros.org/collada_urdf # http://openrave.org/docs/latest_stable/collada_robot_extensions/ # http://openrave.org/docs/0.8.2/robots_overview/#openrave-xml def parse_shape(link): elem = link.find("origin") if elem is not None: if elem.find("rby") is not None: print('rel=<T t(%s) E(%s)>' % (elem.attrib['xyz'], elem.attrib['rpy'])) else: print('rel=<T t(%s)>' % elem.attrib['xyz']) elem = link.find("geometry/box") if elem is not None: print('type=ST_box size=[%s 0]' % elem.attrib['size']) elem = link.find("geometry/sphere") if elem is not None: print('type=ST_sphere size=[0 0 0 %s]' % elem.attrib['radius']) elem = link.find("geometry/cylinder") if elem is not None: print('type=ST_cylinder size=[0 0 %s %s]' % (elem.attrib['length'], elem.attrib['radius'])) elem = link.find("geometry/mesh") if elem is not None: print('type=ST_mesh mesh=\'%s\'' % elem.attrib['filename']) if elem.find("scale") is not None: print('meshscale=[%s]' % elem.attrib['scale']) elem = link.find("material/color") if elem is not None: print('color=[%s]' % elem.attrib['rgba']) elem = link.find("material") if elem is not None: if elem.attrib['name'] is not None: print('colorName=%s' % elem.attrib['name']) # TODO: this is case sensitive... def parse_body(body): name = body.attrib['name'] print('body %s { X=<' % name) elem = body.find("Body/Translation") if elem is not None: print('t(%s)' % elem.text) elem = body.find("Body/rotationaxis") if elem is not None: rot = [float(i) for i in elem.text.split(' ')] print('d(%f %f %f %f)' % (rot[3], rot[0], rot[1], rot[2])) print('> }\n') # end of body for geom in body.findall("Body/Geom"): print('shape (%s) {' % name) type = geom.attrib['type'] if type == "box": size = [2 * float(i) for i in find_insensitive(geom, "Extents").text.split(' ')] print('type=ST_box size=', size) else: pass #raise NotImplementedError(type) elem = geom.find("translation") if elem is not None: print('rel=<t(%s)>' % elem.text) elem = geom.find("diffuseColor") if elem is not None: print('color=[%s]' % elem.text) print(' }\n') def parse_path(path): xmlData = etree.parse(path) print(xmlData) root = xmlData.getroot() parse_body(root) #bodies = xmlData.find("/Environment") #print(bodies) #bodies = xmlData.findall("/KinBody") #print(bodies) #for body in bodies: # parse_body(body) # TODO: store things as JSONs? def main(): root_directory = os.path.dirname(os.path.abspath(__file__)) openrave_directory = os.path.join(root_directory, '..', 'openrave') rel_path = 'data/ikeatable.kinbody.xml' path = os.path.join(openrave_directory, rel_path) parse_path(path) #connect(use_gui=True) #wait_if_gui('Finish?') #disconnect() if __name__ == '__main__': main()
3,675
Python
31.821428
99
0.596463
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_turtlebot_motion.py
from __future__ import print_function import argparse import random import numpy as np import time import math from collections import OrderedDict, defaultdict from pybullet_tools.utils import load_model, TURTLEBOT_URDF, joints_from_names, \ set_joint_positions, HideOutput, get_bodies, sample_placement, pairwise_collision, \ set_point, Point, create_box, stable_z, TAN, GREY, connect, PI, OrderedSet, \ wait_if_gui, dump_body, set_all_color, BLUE, child_link_from_joint, link_from_name, draw_pose, Pose, pose_from_pose2d, \ get_random_seed, get_numpy_seed, set_random_seed, set_numpy_seed, plan_joint_motion, plan_nonholonomic_motion, \ joint_from_name, safe_zip, draw_base_limits, BodySaver, WorldSaver, LockRenderer, elapsed_time, disconnect, flatten, \ INF, wait_for_duration, get_unbuffered_aabb, draw_aabb, DEFAULT_AABB_BUFFER, get_link_pose, get_joint_positions, \ get_subtree_aabb, get_pairs, get_distance_fn, get_aabb, set_all_static, step_simulation, get_bodies_in_region, \ AABB, update_scene, Profiler, pairwise_link_collision, BASE_LINK, get_collision_data, draw_pose2d, \ normalize_interval, wrap_angle, CIRCULAR_LIMITS, wrap_interval, Euler, rescale_interval, adjust_path BASE_LINK_NAME = 'base_link' BASE_JOINTS = ['x', 'y', 'theta'] DRAW_Z = 1e-3 DRAW_LENGTH = 0.5 MIN_AABB_VOLUME = DEFAULT_AABB_BUFFER**3 ################################################## def create_custom_base_limits(robot, base_limits): return {joint_from_name(robot, joint): limits for joint, limits in safe_zip(BASE_JOINTS[:2], zip(*base_limits))} def sample_placements(body_surfaces, obstacles=None, savers=[], min_distances={}): if obstacles is None: obstacles = OrderedSet(get_bodies()) - set(body_surfaces) obstacles = list(obstacles) savers = list(savers) + [BodySaver(obstacle) for obstacle in obstacles] if not isinstance(min_distances, dict): min_distances = {body: min_distances for body in body_surfaces} # TODO: max attempts here for body, surface in body_surfaces.items(): # TODO: shuffle min_distance = min_distances.get(body, 0.) while True: pose = sample_placement(body, surface) if pose is None: for saver in savers: saver.restore() return False for saver in savers: obstacle = saver.body if obstacle in [body, surface]: continue saver.restore() if pairwise_collision(body, obstacle, max_distance=min_distance): break else: obstacles.append(body) break for saver in savers: saver.restore() return True def draw_path(path2d, z=DRAW_Z, **kwargs): if path2d is None: return [] #return list(flatten(draw_pose(pose_from_pose2d(pose2d, z=z), **kwargs) for pose2d in path2d)) #return list(flatten(draw_pose2d(pose2d, z=z, **kwargs) for pose2d in path2d)) base_z = 1. start = path2d[0] mid_yaw = start[2] #mid_yaw = wrap_interval(mid_yaw) interval = (mid_yaw - PI, mid_yaw + PI) #interval = CIRCULAR_LIMITS draw_pose(pose_from_pose2d(start, z=base_z), length=1, **kwargs) # TODO: draw the current pose # TODO: line between orientations when there is a jump return list(flatten(draw_pose2d(pose2d, z=base_z+rescale_interval( wrap_interval(pose2d[2], interval=interval), old_interval=interval, new_interval=(-0.5, 0.5)), **kwargs) for pose2d in path2d)) def plan_motion(robot, joints, goal_positions, attachments=[], obstacles=None, holonomic=False, reversible=False, **kwargs): attached_bodies = [attachment.child for attachment in attachments] moving_bodies = [robot] + attached_bodies if obstacles is None: obstacles = get_bodies() obstacles = OrderedSet(obstacles) - set(moving_bodies) if holonomic: return plan_joint_motion(robot, joints, goal_positions, attachments=attachments, obstacles=obstacles, **kwargs) # TODO: just sample the x, y waypoint and use the resulting orientation # TODO: remove overlapping configurations/intervals due to circular joints return plan_nonholonomic_motion(robot, joints, goal_positions, reversible=reversible, linear_tol=1e-6, angular_tol=0., attachments=attachments, obstacles=obstacles, **kwargs) ################################################## def problem1(n_obstacles=10, wall_side=0.1, obst_width=0.25, obst_height=0.5): floor_extent = 5.0 base_limits = (-floor_extent/2.*np.ones(2), +floor_extent/2.*np.ones(2)) floor_height = 0.001 floor = create_box(floor_extent, floor_extent, floor_height, color=TAN) set_point(floor, Point(z=-floor_height/2.)) wall1 = create_box(floor_extent + wall_side, wall_side, wall_side, color=GREY) set_point(wall1, Point(y=floor_extent/2., z=wall_side/2.)) wall2 = create_box(floor_extent + wall_side, wall_side, wall_side, color=GREY) set_point(wall2, Point(y=-floor_extent/2., z=wall_side/2.)) wall3 = create_box(wall_side, floor_extent + wall_side, wall_side, color=GREY) set_point(wall3, Point(x=floor_extent/2., z=wall_side/2.)) wall4 = create_box(wall_side, floor_extent + wall_side, wall_side, color=GREY) set_point(wall4, Point(x=-floor_extent/2., z=wall_side/2.)) walls = [wall1, wall2, wall3, wall4] initial_surfaces = OrderedDict() for _ in range(n_obstacles): body = create_box(obst_width, obst_width, obst_height, color=GREY) initial_surfaces[body] = floor obstacles = walls + list(initial_surfaces) initial_conf = np.array([+floor_extent/3, -floor_extent/3, 3*PI/4]) goal_conf = -initial_conf with HideOutput(): robot = load_model(TURTLEBOT_URDF) base_joints = joints_from_names(robot, BASE_JOINTS) # base_link = child_link_from_joint(base_joints[-1]) base_link = link_from_name(robot, BASE_LINK_NAME) set_all_color(robot, BLUE) dump_body(robot) set_point(robot, Point(z=stable_z(robot, floor))) draw_pose(Pose(), parent=robot, parent_link=base_link, length=0.5) set_joint_positions(robot, base_joints, initial_conf) sample_placements(initial_surfaces, obstacles=[robot] + walls, savers=[BodySaver(robot, joints=base_joints, positions=goal_conf)], min_distances=10e-2) return robot, base_limits, goal_conf, obstacles ################################################## def iterate_path(robot, joints, path, step_size=None): # 1e-2 | None if path is None: return path = adjust_path(robot, joints, path) with LockRenderer(): handles = draw_path(path) wait_if_gui(message='Begin?') for i, conf in enumerate(path): set_joint_positions(robot, joints, conf) if step_size is None: wait_if_gui(message='{}/{} Continue?'.format(i, len(path))) else: wait_for_duration(duration=step_size) wait_if_gui(message='Finish?') def main(): parser = argparse.ArgumentParser() parser.add_argument('-c', '--cfree', action='store_true', help='When enabled, disables collision checking.') # parser.add_argument('-p', '--problem', default='test_pour', choices=sorted(problem_fn_from_name), # help='The name of the problem to solve.') parser.add_argument('--holonomic', action='store_true', # '-h', help='') parser.add_argument('-l', '--lock', action='store_false', help='') parser.add_argument('-s', '--seed', default=None, type=int, help='The random seed to use.') parser.add_argument('-v', '--viewer', action='store_false', help='') args = parser.parse_args() connect(use_gui=args.viewer) seed = args.seed #seed = 0 #seed = time.time() set_random_seed(seed=seed) # None: 2147483648 = 2**31 set_numpy_seed(seed=seed) print('Random seed:', get_random_seed(), random.random()) print('Numpy seed:', get_numpy_seed(), np.random.random()) ######################### robot, base_limits, goal_conf, obstacles = problem1() draw_base_limits(base_limits) custom_limits = create_custom_base_limits(robot, base_limits) base_joints = joints_from_names(robot, BASE_JOINTS) base_link = link_from_name(robot, BASE_LINK_NAME) if args.cfree: obstacles = [] # for obstacle in obstacles: # draw_aabb(get_aabb(obstacle)) # Updates automatically resolutions = None #resolutions = np.array([0.05, 0.05, math.radians(10)]) set_all_static() # Doesn't seem to affect region_aabb = AABB(lower=-np.ones(3), upper=+np.ones(3)) draw_aabb(region_aabb) step_simulation() # Need to call before get_bodies_in_region #update_scene() # TODO: https://github.com/bulletphysics/bullet3/pull/3331 bodies = get_bodies_in_region(region_aabb) print(len(bodies), bodies) # https://github.com/bulletphysics/bullet3/search?q=broadphase # https://github.com/bulletphysics/bullet3/search?p=1&q=getCachedOverlappingObjects&type=&utf8=%E2%9C%93 # https://andysomogyi.github.io/mechanica/bullet.html # http://www.cs.kent.edu/~ruttan/GameEngines/lectures/Bullet_User_Manual #draw_pose(get_link_pose(robot, base_link), length=0.5) for conf in [get_joint_positions(robot, base_joints), goal_conf]: draw_pose(pose_from_pose2d(conf, z=DRAW_Z), length=DRAW_LENGTH) aabb = get_aabb(robot) #aabb = get_subtree_aabb(robot, base_link) draw_aabb(aabb) for link in [BASE_LINK, base_link]: print(link, get_collision_data(robot, link), pairwise_link_collision(robot, link, robot, link)) ######################### saver = WorldSaver() start_time = time.time() profiler = Profiler(field='tottime', num=50) # tottime | cumtime | None profiler.save() with LockRenderer(lock=args.lock): path = plan_motion(robot, base_joints, goal_conf, holonomic=args.holonomic, obstacles=obstacles, custom_limits=custom_limits, resolutions=resolutions, use_aabb=True, cache=True, max_distance=0., restarts=2, iterations=20, smooth=20) # 20 | None saver.restore() #wait_for_duration(duration=1e-3) profiler.restore() ######################### solved = path is not None length = INF if path is None else len(path) cost = sum(get_distance_fn(robot, base_joints, weights=resolutions)(*pair) for pair in get_pairs(path)) print('Solved: {} | Length: {} | Cost: {:.3f} | Runtime: {:.3f} sec'.format( solved, length, cost, elapsed_time(start_time))) if path is None: disconnect() return iterate_path(robot, base_joints, path) disconnect() if __name__ == '__main__': main()
11,128
Python
43.162698
124
0.626168
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_se3.py
#!/usr/bin/env python from __future__ import print_function import numpy as np from pybullet_tools.utils import connect, disconnect, wait_for_user, create_box, dump_body, \ get_link_pose, euler_from_quat, RED, set_camera_pose, create_flying_body, create_shape, get_cylinder_geometry, \ BLUE, get_movable_joints, get_links, SE3, set_joint_positions, \ plan_joint_motion, add_line, GREEN, intrinsic_euler_from_quat SIZE = 1. CUSTOM_LIMITS = { 'x': (-SIZE, SIZE), 'y': (-SIZE, SIZE), 'z': (-SIZE, SIZE), } def main(group=SE3): connect(use_gui=True) set_camera_pose(camera_point=SIZE*np.array([1., -1., 1.])) # TODO: can also create all links and fix some joints # TODO: SE(3) motion planner (like my SE(3) one) where some dimensions are fixed obstacle = create_box(w=SIZE, l=SIZE, h=SIZE, color=RED) #robot = create_cylinder(radius=0.025, height=0.1, color=BLUE) obstacles = [obstacle] collision_id, visual_id = create_shape(get_cylinder_geometry(radius=0.025, height=0.1), color=BLUE) robot = create_flying_body(group, collision_id, visual_id) body_link = get_links(robot)[-1] joints = get_movable_joints(robot) joint_from_group = dict(zip(group, joints)) print(joint_from_group) #print(get_aabb(robot, body_link)) dump_body(robot, fixed=False) custom_limits = {joint_from_group[j]: l for j, l in CUSTOM_LIMITS.items()} # sample_fn = get_sample_fn(robot, joints, custom_limits=custom_limits) # for i in range(10): # conf = sample_fn() # set_joint_positions(robot, joints, conf) # wait_for_user('Iteration: {}'.format(i)) # return initial_point = SIZE*np.array([-1., -1., 0]) #initial_point = -1.*np.ones(3) final_point = -initial_point initial_euler = np.zeros(3) add_line(initial_point, final_point, color=GREEN) initial_conf = np.concatenate([initial_point, initial_euler]) final_conf = np.concatenate([final_point, initial_euler]) set_joint_positions(robot, joints, initial_conf) #print(initial_point, get_link_pose(robot, body_link)) #set_pose(robot, Pose(point=-1.*np.ones(3))) # TODO: sample orientation uniformly at random # http://planning.cs.uiuc.edu/node198.html #from pybullet_tools.transformations import random_quaternion path = plan_joint_motion(robot, joints, final_conf, obstacles=obstacles, self_collisions=False, custom_limits=custom_limits) if path is None: disconnect() return for i, conf in enumerate(path): set_joint_positions(robot, joints, conf) point, quat = get_link_pose(robot, body_link) #euler = euler_from_quat(quat) euler = intrinsic_euler_from_quat(quat) print(conf) print(point, euler) wait_for_user('Step: {}/{}'.format(i, len(path))) wait_for_user('Finish?') disconnect() if __name__ == '__main__': main()
2,957
Python
34.214285
116
0.646601
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_movo.py
#!/usr/bin/env python from __future__ import print_function import time import numpy as np import pybullet as p from examples.test_franka import test_retraction from pybullet_tools.ikfast.ikfast import get_ik_joints, check_ik_solver from pybullet_tools.movo_constants import get_closed_positions, get_open_positions, TOOL_LINK, get_gripper_joints, ARMS, \ MOVO_URDF, MOVO_INFOS, RIGHT, get_arm_joints, MOVO_COLOR, BASE_JOINTS from pybullet_tools.pr2_utils import get_side_grasps, close_until_collision from pybullet_tools.utils import add_data_path, connect, dump_body, load_model, disconnect, wait_if_gui, \ get_sample_fn, set_joint_positions, LockRenderer, link_from_name, HideOutput, \ joints_from_names, set_color, get_links, get_max_limits, get_min_limits, get_extend_fn, get_link_pose, \ get_joint_names, draw_pose, remove_handles, draw_base_limits, \ elapsed_time, create_box, RED, \ unit_pose, multiply, set_pose, assign_link_colors, set_all_color def test_close_gripper(robot, arm): gripper_joints = get_gripper_joints(robot, arm) extend_fn = get_extend_fn(robot, gripper_joints) for positions in extend_fn(get_open_positions(robot, arm), get_closed_positions(robot, arm)): set_joint_positions(robot, gripper_joints, positions) print(positions) wait_if_gui('Continue?') def test_grasps(robot, block): for arm in ARMS: gripper_joints = get_gripper_joints(robot, arm) tool_link = link_from_name(robot, TOOL_LINK.format(arm)) tool_pose = get_link_pose(robot, tool_link) #handles = draw_pose(tool_pose) #grasps = get_top_grasps(block, under=True, tool_pose=unit_pose()) grasps = get_side_grasps(block, under=True, tool_pose=unit_pose()) for i, grasp_pose in enumerate(grasps): block_pose = multiply(tool_pose, grasp_pose) set_pose(block, block_pose) close_until_collision(robot, gripper_joints, bodies=[block], open_conf=get_open_positions(robot, arm), closed_conf=get_closed_positions(robot, arm)) handles = draw_pose(block_pose) wait_if_gui('Grasp {}'.format(i)) remove_handles(handles) ##################################### def main(num_iterations=10): # The URDF loader seems robust to package:// and slightly wrong relative paths? connect(use_gui=True) add_data_path() plane = p.loadURDF("plane.urdf") side = 0.05 block = create_box(w=side, l=side, h=side, color=RED) start_time = time.time() with LockRenderer(): with HideOutput(): # TODO: MOVO must be loaded last robot = load_model(MOVO_URDF, fixed_base=True) #set_all_color(robot, color=MOVO_COLOR) assign_link_colors(robot) base_joints = joints_from_names(robot, BASE_JOINTS) draw_base_limits((get_min_limits(robot, base_joints), get_max_limits(robot, base_joints)), z=1e-2) print('Load time: {:.3f}'.format(elapsed_time(start_time))) dump_body(robot) #print(get_colliding(robot)) #for arm in ARMS: # test_close_gripper(robot, arm) #test_grasps(robot, block) arm = RIGHT tool_link = link_from_name(robot, TOOL_LINK.format(arm)) #joint_names = HEAD_JOINTS #joints = joints_from_names(robot, joint_names) joints = base_joints + get_arm_joints(robot, arm) #joints = get_movable_joints(robot) print('Joints:', get_joint_names(robot, joints)) ik_info = MOVO_INFOS[arm] check_ik_solver(ik_info) ik_joints = get_ik_joints(robot, ik_info, tool_link) #fixed_joints = [] fixed_joints = ik_joints[:1] #fixed_joints = ik_joints wait_if_gui('Start?') sample_fn = get_sample_fn(robot, joints) handles = [] for i in range(num_iterations): conf = sample_fn() print('Iteration: {}/{} | Conf: {}'.format(i+1, num_iterations, np.array(conf))) set_joint_positions(robot, joints, conf) tool_pose = get_link_pose(robot, tool_link) remove_handles(handles) handles = draw_pose(tool_pose) wait_if_gui() #conf = next(ikfast_inverse_kinematics(robot, MOVO_INFOS[arm], tool_link, tool_pose, # fixed_joints=fixed_joints, max_time=0.1), None) #if conf is not None: # set_joint_positions(robot, ik_joints, conf) #wait_if_gui() test_retraction(robot, ik_info, tool_link, fixed_joints=fixed_joints, max_time=0.05, max_candidates=100) disconnect() if __name__ == '__main__': main()
4,625
Python
39.578947
122
0.637189
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_clone.py
#!/usr/bin/env python from __future__ import print_function from pybullet_tools.pr2_utils import PR2_GROUPS from pybullet_tools.utils import HideOutput, disconnect, set_base_values, joint_from_name, connect, wait_if_gui, \ dump_world, get_link_name, wait_if_gui, clone_body, get_link_parent, get_link_descendants, load_model def test_clone_robot(pr2): # TODO: j toggles frames, p prints timings, w is wire, a is boxes new_pr2 = clone_body(pr2, visual=True, collision=False) #new_pr2 = clone_body_editor(pr2, visual=True, collision=True) dump_world() #print(load_srdf_collisions()) #print(load_dae_collisions()) # TODO: some unimportant quats are off for both URDF and other # TODO: maybe all the frames are actually correct when I load things this way? # TODO: the visual geometries are off but not the collision frames? """ import numpy as np for link in get_links(pr2): if not get_visual_data(new_pr2, link): # pybullet.error: Error receiving visual shape info? continue #print(get_link_name(pr2, link)) data1 = VisualShapeData(*get_visual_data(pr2, link)[0]) data2 = VisualShapeData(*get_visual_data(new_pr2, link)[0]) pose1 = (data1.localVisualFrame_position, data1.localVisualFrame_orientation) pose2 = (data2.localVisualFrame_position, data2.localVisualFrame_orientation) #pose1 = get_link_pose(pr2, link) # Links are fine #pose2 = get_link_pose(new_pr2, link) #pose1 = get_joint_parent_frame(pr2, link) #pose2 = get_joint_parent_frame(new_pr2, link) #pose1 = get_joint_inertial_pose(pr2, link) # Inertia is fine #pose2 = get_joint_inertial_pose(new_pr2, link) if not np.allclose(pose1[0], pose2[0], rtol=0, atol=1e-3): print('Point', get_link_name(pr2, link), link, pose1[0], pose2[0]) #print(data1) #print(data2) #print(get_joint_parent_frame(pr2, link), get_joint_parent_frame(new_pr2, link)) print(get_joint_inertial_pose(pr2, link)) #, get_joint_inertial_pose(new_pr2, link)) print() if not np.allclose(euler_from_quat(pose1[1]), euler_from_quat(pose2[1]), rtol=0, atol=1e-3): print('Quat', get_link_name(pr2, link), link, euler_from_quat(pose1[1]), euler_from_quat(pose2[1])) joint_info1 = get_joint_info(pr2, link) joint_info2 = get_joint_info(new_pr2, link) # TODO: the axis is off for some of these if not np.allclose(joint_info1.jointAxis, joint_info2.jointAxis, rtol=0, atol=1e-3): print('Axis', get_link_name(pr2, link), link, joint_info1.jointAxis, joint_info2.jointAxis) """ set_base_values(new_pr2, (2, 0, 0)) wait_if_gui() # TODO: the drake one has a large out-of-place cylinder as well def test_clone_arm(pr2): first_joint_name = PR2_GROUPS['left_arm'][0] first_joint = joint_from_name(pr2, first_joint_name) parent_joint = get_link_parent(pr2, first_joint) print(get_link_name(pr2, parent_joint), parent_joint, first_joint_name, first_joint) print(get_link_descendants(pr2, first_joint)) # TODO: least common ancestor links = [first_joint] + get_link_descendants(pr2, first_joint) new_arm = clone_body(pr2, links=links, collision=False) dump_world() set_base_values(pr2, (-2, 0, 0)) wait_if_gui() def main(): connect(use_gui=True) with HideOutput(): pr2 = load_model("models/pr2_description/pr2.urdf") test_clone_robot(pr2) test_clone_arm(pr2) wait_if_gui('Finish?') disconnect() if __name__ == '__main__': main()
3,645
Python
43.463414
114
0.651578
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_tamp_xml.py
#!/usr/bin/env python from __future__ import print_function import colorsys import glob import os import pybullet as p import random import sys import numpy as np from lxml import etree from pybullet_tools.pr2_utils import DRAKE_PR2_URDF, set_group_conf from pybullet_tools.utils import STATIC_MASS, CLIENT, connect, \ disconnect, set_pose, wait_if_gui, load_model, HideOutput, base_values_from_pose, create_shape, \ get_mesh_geometry, point_from_pose, set_camera_pose, draw_global_system from pybullet_tools.utils import quaternion_from_matrix # https://docs.python.org/3.5/library/xml.etree.elementtree.html # https://lxml.de/tutorial.html def parse_array(element): return np.array(element.text.split(), dtype=np.float) def parse_pose(element): homogenous = [0, 0, 0, 1] matrix = np.reshape(np.concatenate([parse_array(element), homogenous]), [4, 4]) point = matrix[:3, 3] quat = quaternion_from_matrix(matrix) return (point, quat) def parse_boolean(element): text = element.text if text == 'true': return True if text == 'false': return False raise ValueError(text) MAX_INT = sys.maxsize + 1 def parse_object(obj, mesh_directory): name = obj.find('name').text mesh_filename = obj.find('geom').text geom = get_mesh_geometry(os.path.join(mesh_directory, mesh_filename)) pose = parse_pose(obj.find('pose')) movable = parse_boolean(obj.find('moveable')) color = (.75, .75, .75, 1) if 'red' in name: color = (1, 0, 0, 1) elif 'green' in name: color = (0, 1, 0, 1) elif 'blue' in name: color = (0, 0, 1, 1) elif movable: # TODO: assign new color #size = 2 * MAX_INT #size = 255 #n = id(obj) % size #n = hash(obj) % size #h = float(n) / size h = random.random() r, g, b = colorsys.hsv_to_rgb(h, .75, .75) color = (r, g, b, 1) print(name, mesh_filename, movable, color) collision_id, visual_id = create_shape(geom, color=color) body_id = p.createMultiBody(baseMass=STATIC_MASS, baseCollisionShapeIndex=collision_id, baseVisualShapeIndex=visual_id, physicsClientId=CLIENT) set_pose(body_id, pose) return body_id def parse_robot(robot): name = robot.find('name').text urdf = robot.find('urdf').text fixed_base = not parse_boolean(robot.find('movebase')) print(name, urdf, fixed_base) pose = parse_pose(robot.find('basepose')) torso = parse_array(robot.find('torso')) left_arm = parse_array(robot.find('left_arm')) right_arm = parse_array(robot.find('right_arm')) assert (name == 'pr2') with HideOutput(): robot_id = load_model(DRAKE_PR2_URDF, fixed_base=True) set_pose(robot_id, pose) #set_group_conf(robot_id, 'base', base_values_from_pose(pose)) set_group_conf(robot_id, 'torso', torso) set_group_conf(robot_id, 'left_arm', left_arm) set_group_conf(robot_id, 'right_arm', right_arm) #set_point(robot_id, Point(z=point_from_pose(pose)[2])) # TODO: base pose isn't right # print(robot.tag) # print(robot.attrib) # print(list(robot.iter('basepose'))) return robot_id DISC = 'disc' BLOCK = 'cube' PEG = 'peg' def main(): benchmark = 'tmp-benchmark-data' problem = 'problem1' # Hanoi #problem = 'problem2' # Blocksworld #problem = 'problem3' # Clutter #problem = 'problem4' # Nonmono root_directory = os.path.dirname(os.path.abspath(__file__)) directory = os.path.join(root_directory, '..', 'problems', benchmark, problem) [mesh_directory] = list(filter(os.path.isdir, (os.path.join(directory, o) for o in os.listdir(directory) if o.endswith('meshes')))) [xml_path] = [os.path.join(directory, o) for o in os.listdir(directory) if o.endswith('xml')] if os.path.isdir(xml_path): xml_path = glob.glob(os.path.join(xml_path, '*.xml'))[0] print(mesh_directory) print(xml_path) xml_data = etree.parse(xml_path) connect(use_gui=True) #add_data_path() #load_pybullet("plane.urdf") draw_global_system() set_camera_pose(camera_point=[+1, -1, 1]) #root = xml_data.getroot() #print(root.items()) for obj in xml_data.findall('/objects/obj'): parse_object(obj, mesh_directory) for robot in xml_data.findall('/robots/robot'): parse_robot(robot) wait_if_gui() disconnect() if __name__ == '__main__': main()
4,511
Python
31.228571
106
0.629129
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_franka.py
#!/usr/bin/env python from __future__ import print_function import pybullet as p from pybullet_tools.utils import add_data_path, connect, dump_body, disconnect, wait_for_user, \ get_movable_joints, get_sample_fn, set_joint_positions, get_joint_name, LockRenderer, link_from_name, get_link_pose, \ multiply, Pose, Point, interpolate_poses, HideOutput, draw_pose, set_camera_pose, load_pybullet, \ assign_link_colors, add_line, point_from_pose, remove_handles, BLUE from pybullet_tools.ikfast.franka_panda.ik import PANDA_INFO, FRANKA_URDF from pybullet_tools.ikfast.ikfast import get_ik_joints, either_inverse_kinematics, check_ik_solver def test_retraction(robot, info, tool_link, distance=0.1, **kwargs): ik_joints = get_ik_joints(robot, info, tool_link) start_pose = get_link_pose(robot, tool_link) end_pose = multiply(start_pose, Pose(Point(z=-distance))) handles = [add_line(point_from_pose(start_pose), point_from_pose(end_pose), color=BLUE)] #handles.extend(draw_pose(start_pose)) #handles.extend(draw_pose(end_pose)) path = [] pose_path = list(interpolate_poses(start_pose, end_pose, pos_step_size=0.01)) for i, pose in enumerate(pose_path): print('Waypoint: {}/{}'.format(i+1, len(pose_path))) handles.extend(draw_pose(pose)) conf = next(either_inverse_kinematics(robot, info, tool_link, pose, **kwargs), None) if conf is None: print('Failure!') path = None wait_for_user() break set_joint_positions(robot, ik_joints, conf) path.append(conf) wait_for_user() # for conf in islice(ikfast_inverse_kinematics(robot, info, tool_link, pose, max_attempts=INF, max_distance=0.5), 1): # set_joint_positions(robot, joints[:len(conf)], conf) # wait_for_user() remove_handles(handles) return path ##################################### def main(): connect(use_gui=True) add_data_path() draw_pose(Pose(), length=1.) set_camera_pose(camera_point=[1, -1, 1]) plane = p.loadURDF("plane.urdf") with LockRenderer(): with HideOutput(True): robot = load_pybullet(FRANKA_URDF, fixed_base=True) assign_link_colors(robot, max_colors=3, s=0.5, v=1.) #set_all_color(robot, GREEN) obstacles = [plane] # TODO: collisions with the ground dump_body(robot) print('Start?') wait_for_user() info = PANDA_INFO tool_link = link_from_name(robot, 'panda_hand') draw_pose(Pose(), parent=robot, parent_link=tool_link) joints = get_movable_joints(robot) print('Joints', [get_joint_name(robot, joint) for joint in joints]) check_ik_solver(info) sample_fn = get_sample_fn(robot, joints) for i in range(10): print('Iteration:', i) conf = sample_fn() set_joint_positions(robot, joints, conf) wait_for_user() test_retraction(robot, info, tool_link, use_pybullet=False, max_distance=0.1, max_time=0.05, max_candidates=100) disconnect() if __name__ == '__main__': main()
3,124
Python
36.650602
125
0.633483
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_json.py
#!/usr/bin/env python from __future__ import print_function import json import os from pybullet_tools.parse_json import parse_pose, parse_robot, parse_region, parse_body from pybullet_tools.utils import connect, \ disconnect, wait_for_interrupt, point_from_pose, set_camera_pose, \ reset_simulation, wait_if_gui from pybullet_tools.pr2_problems import Problem BODY_FIELDS = [u'table_names', u'sink_names', u'stove_names'] # [u'goal_cleaned', u'regions', u'goal_stackings', u'name', # u'sink_names', u'goal_regions', u'goal_cooked', # u'goal_config', u'table_names', u'floor_object_names', # u'grasp_types', u'goal_holding', u'object_names', u'stove_names', u'goal_poses'] def parse_task(task, robots, bodies, regions): [robot] = robots.values() arm = 'left' goal_holding = [] if task['goal_holding'] is not None: goal_holding.append((arm, bodies[task['goal_holding']])) # TODO: combine robots, bodies, regions arms = [arm] movable = [bodies[n] for n in task['object_names']] grasp_types = [grasp_type.lower() for grasp_type in task['grasp_types']] #grasp_types = ['top'] sinks = [bodies[n] for n in task['sink_names']] stoves = [bodies[n] for n in task['stove_names']] surfaces = [bodies[n] for n in task['table_names']] + list(regions.values()) + sinks + stoves #buttons = tuple() #assert not task['goal_poses'] assert task['goal_config'] is None goal_conf = None goal_on = [(bodies[n1], bodies[n2]) for n1, n2 in task['goal_stackings'].items()] + \ [(bodies[n1], regions[n2]) for n1, n2 in task['goal_regions'].items()] goal_cleaned = [bodies[n] for n in task['goal_cleaned']] goal_cooked = [bodies[n] for n in task['goal_cooked']] body_names = {body: name for name, body in list(bodies.items()) + list(regions.items())} return Problem(robot=robot, arms=arms, movable=movable, grasp_types=grasp_types, surfaces=surfaces, sinks=sinks, stoves=stoves, goal_conf=goal_conf, goal_on=goal_on, goal_cleaned=goal_cleaned, goal_cooked=goal_cooked, body_names=body_names) ################################################## JSON_DIRECTORY = 'problems/json/' def get_json_directory(): root_directory = os.path.dirname(os.path.abspath(__file__)) return os.path.join(root_directory, '..', JSON_DIRECTORY) def get_json_filenames(): return os.listdir(get_json_directory()) def load_json_problem(problem_filename): reset_simulation() json_path = os.path.join(get_json_directory(), problem_filename) with open(json_path, 'r') as f: problem_json = json.loads(f.read()) set_camera_pose(point_from_pose(parse_pose(problem_json['camera']))) task_json = problem_json['task'] important_bodies = [] for field in BODY_FIELDS: important_bodies.extend(task_json[field]) robots = {robot['name']: parse_robot(robot) for robot in problem_json['robots']} bodies = {body['name']: parse_body(body, (body['name'] in important_bodies)) for body in problem_json['bodies']} regions = {region['name']: parse_region(region) for region in task_json['regions']} #print(get_image()) return parse_task(task_json, robots, bodies, regions) ################################################## # TODO: cannot solve any FFRob FFROB = ['blocks_row', 'bury', 'clean', 'cook', 'dig', 'invert', 'move', 'move_distractions', 'organize', 'panel', 'real_regrasp', 'regrasp', 'regrasp_distractions', 'table', 'transporter', 'walls'] # ['blocked.json', # 'dantam.json', 'dantam2.json', 'dantam_3.json', 'decision_namo.json', # 'decision_wall_namo_2.json', 'decision_wall_namo_3.json', # 'dinner.json', 'disconnected.json', 'distract_0.json', 'distract_10.json', # 'distract_12.json', 'distract_16.json', 'distract_20.json', 'distract_24.json', # 'distract_30.json', 'distract_4.json', 'distract_40.json', 'distract_8.json', # 'distractions.json', 'easy_dinner.json', 'kitchen.json', # 'move_regrasp.json', 'move_several_10.json', # 'move_several_12.json', 'move_several_14.json', 'move_several_16.json', 'move_several_18.json', # 'move_several_20.json', 'move_several_24.json', 'move_several_28.json', 'move_several_32.json', # 'move_several_4.json', 'move_several_8.json', 'nonmonotonic_4_1.json', 'nonmonotonic_4_2.json', # 'nonmonotonic_4_3.json', 'nonmonotonic_4_4.json', 'push_table.json', # 'push_wall.json', 'rearrangement_10.json', 'rearrangement_12.json', # 'rearrangement_14.json', 'rearrangement_16.json', 'rearrangement_18.json', 'rearrangement_20.json', # 'rearrangement_4.json', 'rearrangement_6.json', 'rearrangement_8.json', # 'replace.json', 'separate_2.json', 'separate_4.json', 'separate_6.json', # 'separate_7.json', 'shelf_arrangement.json', 'simple.json', 'simple2.json', 'simple_holding.json', # 'simple_namo.json', 'simple_push.json', # 'srivastava_table.json', 'stacking.json', # 'trivial_namo.json', 'two_tables_1.json', 'two_tables_2.json', # 'two_tables_3.json', 'two_tables_4.json', 'wall_namo_2.json', 'wall_namo_3.json'] IJRR = [] # HBF RSS = ['blocked.json', 'dinner.json', 'disconnected.json', 'distract_0.json', 'distract_10.json', 'distract_12.json', 'distract_16.json', 'distract_20.json', 'distract_24.json', 'distract_30.json', 'distract_4.json', 'distract_40.json', 'distract_8.json', 'distractions.json', 'easy_dinner.json', 'kitchen.json', 'move_regrasp.json', 'move_several_10.json', 'move_several_12.json', 'move_several_14.json', 'move_several_16.json', 'move_several_18.json', 'move_several_20.json', 'move_several_24.json', 'move_several_28.json', 'move_several_32.json', 'move_several_4.json', 'move_several_8.json', 'nonmonotonic_4_1.json', 'nonmonotonic_4_2.json', 'push_table.json', 'push_wall.json', 'rearrangement_10.json', 'rearrangement_12.json', 'rearrangement_14.json', 'rearrangement_16.json', 'rearrangement_18.json', 'rearrangement_20.json', 'rearrangement_4.json', 'rearrangement_6.json', 'rearrangement_8.json', 'replace.json', 'separate_2.json', 'separate_4.json', 'separate_6.json', 'separate_7.json', 'shelf_arrangement.json', 'simple.json', 'simple2.json', 'simple_holding.json', 'simple_push.json', 'srivastava_table.json', 'stacking.json', 'two_tables_1.json', 'two_tables_2.json', 'two_tables_3.json', 'two_tables_4.json'] IJCAI = ['exists_hold_obs_0.json', 'exists_hold_obs_1.json', 'exists_hold_obs_2.json', 'exists_hold_obs_4.json', 'exists_hold_obs_5.json', 'exists_holding_1.json', 'exists_holding_2.json', 'exists_holding_3.json', 'exists_holding_blocked.json', 'exists_holding_unreachable.json', 'exists_region_1.json', 'sink_stove_2_16.json', 'sink_stove_2_20.json', 'sink_stove_2_4.json', 'sink_stove_2_8.json', 'sink_stove_4_0.json', 'sink_stove_4_12.json', 'sink_stove_4_15.json', 'sink_stove_4_16.json', 'sink_stove_4_20.json', 'sink_stove_4_30.json', 'sink_stove_4_4.json', 'sink_stove_4_40.json', 'sink_stove_4_8.json'] ################################################## SCREENSHOT_DIR = 'images/json' def main(screenshot=False): connect(use_gui=True) print(get_json_filenames()) #problem_filenames = sorted(os.listdir(openrave_directory)) #problem_filenames = ['{}.json'.format(name) for name in FFROB] #problem_filenames = ['sink_stove_4_30.json'] # 'dinner.json' | 'simple.json' problem_filenames = ['simple.json'] # 'dinner.json' | 'simple.json' # Mac width/height #width = 2560 #height = 1600 # #640, 480 for problem_filename in problem_filenames: load_json_problem(problem_filename) if screenshot: problem_name = problem_filename.split('.')[0] image_filename = "{}.png".format(problem_name) image_path = os.path.join(SCREENSHOT_DIR, image_filename) wait_for_interrupt(max_time=0.5) os.system("screencapture -R {},{},{},{} {}".format( 225, 200, 600, 500, image_path)) else: wait_if_gui() disconnect() if __name__ == '__main__': main()
8,112
Python
44.578651
115
0.642751
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_models.py
import os import pybullet as p from pybullet_tools.utils import create_mesh, set_point, read_pcd_file, disconnect, \ wait_if_gui, mesh_from_points, get_links, get_num_links, connect, load_pybullet, \ create_obj, WHITE, get_client, NULL_ID, set_color, get_all_links SODA_CLOUD = 'soda.pcd' CLOUDS = { 'oil': 'oilBottle.pcd', 'soup': 'soup16.pcd', 'block': SODA_CLOUD, 'red': SODA_CLOUD, 'orange': SODA_CLOUD, 'green': SODA_CLOUD, 'blue': SODA_CLOUD, 'purple': SODA_CLOUD, } SODA_MESH = 'soda.off' MESHES = { # Cap is literally the bottle cap 'oil': 'oil_bottle_simple_new.off', # oil_bottle_simple_cap, oil_bottle_simple_new, oilBottleWithCapNew, oilBottleWithCap, ... 'soup': 'soup16.off', # 'block': SODA_MESH, # soda.off, soda_original.off, soda_points.off 'red': SODA_MESH, 'orange': SODA_MESH, 'green': SODA_MESH, 'blue': SODA_MESH, 'purple': SODA_MESH, } LIS_DIRECTORY = "/Users/caelan/Programs/LIS/git/lis-data/" def test_lis(world): #model = 'oil' model = 'soup' point_path = os.path.join(LIS_DIRECTORY, 'clouds', CLOUDS[model]) mesh_path = os.path.join(LIS_DIRECTORY, 'meshes', MESHES[model]) # off | ply | wrl #ycb_path = os.path.join(DATA_DIRECTORY, 'ycb', 'plastic_wine_cup', 'meshes', 'tsdf.stl') # stl | ply ycb_path = os.path.join(LIS_DIRECTORY, 'ycb', 'plastic_wine_cup', 'textured_meshes', 'optimized_tsdf_texture_mapped_mesh.obj') # ply print(point_path) print(mesh_path) print(ycb_path) #mesh = read_mesh_off(mesh_path, scale=0.001) #print(mesh) points = read_pcd_file(point_path) #print(points) #print(convex_hull(points)) mesh = mesh_from_points(points) #print(mesh) body = create_mesh(mesh, color=(1, 0, 0, 1)) #print(get_num_links(body)) #print(mesh_from_body(body)) #set_point(body, (1, 1, 1)) wait_if_gui() ##################################### YCB_DIRECTORY = "/Users/caelan/Programs/ycb_benchmarks/processed_data/" YCB_TEMPLATE = '{:03d}_{}' POISSON = 'poisson/' TSDF = 'tsdf/' OBJ_PATH = 'textured.obj' PNG_PATH = 'textured.png' SENSOR = POISSON # POISSON | TSDF def get_ycb_objects(): return {name.split('_', 1)[-1]: name for name in os.listdir(YCB_DIRECTORY) if os.path.isdir(os.path.join(YCB_DIRECTORY, name))} def set_texture(body, image_path): #if color is not None: # set_color(body, color) assert image_path.endswith('.png') texture = p.loadTexture(image_path) assert 0 <= texture p.changeVisualShape(body, linkIndex=NULL_ID, shapeIndex=NULL_ID, #rgbaColor=WHITE, textureUniqueId=texture, #specularColor=(0, 0, 0), physicsClientId=get_client()) return texture def test_ycb(world): name = 'mustard_bottle' # potted_meat_can | cracker_box | sugar_box | mustard_bottle | bowl path_from_name = get_ycb_objects() print(path_from_name) ycb_directory = os.path.join(YCB_DIRECTORY, path_from_name[name], SENSOR) obj_path = os.path.join(ycb_directory, OBJ_PATH) image_path = os.path.join(ycb_directory, PNG_PATH) print(obj_path) #body = load_pybullet(obj_path) #, fixed_base=True) body = create_obj(obj_path, color=WHITE) set_texture(body, image_path) for link in get_all_links(body): set_color(body, link=link, color=WHITE) wait_if_gui() ##################################### def main(): world = connect(use_gui=True) #test_lis(world) test_ycb(world) disconnect() if __name__ == '__main__': main()
3,595
Python
28.719008
105
0.619471
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_kuka_pick.py
#!/usr/bin/env python from __future__ import print_function from pybullet_tools.kuka_primitives import BodyPose, BodyConf, Command, get_grasp_gen, \ get_ik_fn, get_free_motion_gen, get_holding_motion_gen from pybullet_tools.utils import WorldSaver, enable_gravity, connect, dump_world, set_pose, \ draw_global_system, draw_pose, set_camera_pose, Pose, Point, set_default_camera, stable_z, \ BLOCK_URDF, load_model, wait_if_gui, disconnect, DRAKE_IIWA_URDF, wait_if_gui, update_state, disable_real_time, HideOutput def plan(robot, block, fixed, teleport): grasp_gen = get_grasp_gen(robot, 'top') ik_fn = get_ik_fn(robot, fixed=fixed, teleport=teleport) free_motion_fn = get_free_motion_gen(robot, fixed=([block] + fixed), teleport=teleport) holding_motion_fn = get_holding_motion_gen(robot, fixed=fixed, teleport=teleport) pose0 = BodyPose(block) conf0 = BodyConf(robot) saved_world = WorldSaver() for grasp, in grasp_gen(block): saved_world.restore() result1 = ik_fn(block, pose0, grasp) if result1 is None: continue conf1, path2 = result1 pose0.assign() result2 = free_motion_fn(conf0, conf1) if result2 is None: continue path1, = result2 result3 = holding_motion_fn(conf1, conf0, block, grasp) if result3 is None: continue path3, = result3 return Command(path1.body_paths + path2.body_paths + path3.body_paths) return None def main(display='execute'): # control | execute | step connect(use_gui=True) disable_real_time() draw_global_system() with HideOutput(): robot = load_model(DRAKE_IIWA_URDF) # KUKA_IIWA_URDF | DRAKE_IIWA_URDF floor = load_model('models/short_floor.urdf') block = load_model(BLOCK_URDF, fixed_base=False) set_pose(block, Pose(Point(y=0.5, z=stable_z(block, floor)))) set_default_camera(distance=2) dump_world() saved_world = WorldSaver() command = plan(robot, block, fixed=[floor], teleport=False) if (command is None) or (display is None): print('Unable to find a plan!') return saved_world.restore() update_state() wait_if_gui('{}?'.format(display)) if display == 'control': enable_gravity() command.control(real_time=False, dt=0) elif display == 'execute': command.refine(num_steps=10).execute(time_step=0.005) elif display == 'step': command.step() else: raise ValueError(display) print('Quit?') wait_if_gui() disconnect() if __name__ == '__main__': main()
2,687
Python
33.461538
126
0.627838
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_turtlebot.py
#!/usr/bin/env python from __future__ import print_function import random import numpy as np from pybullet_tools.utils import connect, load_model, disconnect, wait_if_gui, create_box, set_point, dump_body, \ TURTLEBOT_URDF, HideOutput, LockRenderer, joint_from_name, set_euler, get_euler, get_point, \ set_joint_position, get_joint_positions, pairwise_collision, stable_z, wait_for_duration, get_link_pose, \ link_from_name, get_pose, euler_from_quat, multiply, invert, draw_pose, unit_point, unit_quat, \ remove_debug, get_aabb, draw_aabb, get_subtree_aabb, ROOMBA_URDF, set_all_static, assign_link_colors, \ set_camera_pose, RGBA, draw_point # RGBA colors (alpha is transparency) RED = RGBA(1, 0, 0, 1) TAN = RGBA(0.824, 0.706, 0.549, 1) def main(floor_width=2.0): # Creates a pybullet world and a visualizer for it connect(use_gui=True) set_camera_pose(camera_point=[1, -1, 1], target_point=unit_point()) # Sets the camera's position identity_pose = (unit_point(), unit_quat()) origin_handles = draw_pose(identity_pose, length=1.0) # Draws the origin coordinate system (x:RED, y:GREEN, z:BLUE) # Bodies are described by an integer index floor = create_box(w=floor_width, l=floor_width, h=0.001, color=TAN) # Creates a tan box object for the floor set_point(floor, [0, 0, -0.001 / 2.]) # Sets the [x,y,z] translation of the floor obstacle = create_box(w=0.5, l=0.5, h=0.1, color=RED) # Creates a red box obstacle set_point(obstacle, [0.5, 0.5, 0.1 / 2.]) # Sets the [x,y,z] position of the obstacle print('Position:', get_point(obstacle)) set_euler(obstacle, [0, 0, np.pi / 4]) # Sets the [roll,pitch,yaw] orientation of the obstacle print('Orientation:', get_euler(obstacle)) with LockRenderer(): # Temporarily prevents the renderer from updating for improved loading efficiency with HideOutput(): # Temporarily suppresses pybullet output robot = load_model(TURTLEBOT_URDF) # TURTLEBOT_URDF | ROOMBA_URDF # Loads a robot from a *.urdf file assign_link_colors(robot) robot_z = stable_z(robot, floor) # Returns the z offset required for robot to be placed on floor set_point(robot, [0, 0, robot_z]) # Sets the z position of the robot dump_body(robot) # Prints joint and link information about robot set_all_static() # Joints are also described by an integer index # The turtlebots has explicit joints representing x, y, theta x_joint = joint_from_name(robot, 'x') # Looks up the robot joint named 'x' y_joint = joint_from_name(robot, 'y') # Looks up the robot joint named 'y' theta_joint = joint_from_name(robot, 'theta') # Looks up the robot joint named 'theta' joints = [x_joint, y_joint, theta_joint] base_link = link_from_name(robot, 'base_link') # Looks up the robot link named 'base_link' world_from_obstacle = get_pose(obstacle) # Returns the pose of the origin of obstacle wrt the world frame obstacle_aabb = get_subtree_aabb(obstacle) draw_aabb(obstacle_aabb) random.seed(0) # Sets the random number generator state handles = [] for i in range(10): for handle in handles: remove_debug(handle) print('\nIteration: {}'.format(i)) x = random.uniform(-floor_width/2., floor_width/2.) set_joint_position(robot, x_joint, x) # Sets the current value of the x joint y = random.uniform(-floor_width/2., floor_width/2.) set_joint_position(robot, y_joint, y) # Sets the current value of the y joint yaw = random.uniform(-np.pi, np.pi) set_joint_position(robot, theta_joint, yaw) # Sets the current value of the theta joint values = get_joint_positions(robot, joints) # Obtains the current values for the specified joints print('Joint values: [x={:.3f}, y={:.3f}, yaw={:.3f}]'.format(*values)) world_from_robot = get_link_pose(robot, base_link) # Returns the pose of base_link wrt the world frame position, quaternion = world_from_robot # Decomposing pose into position and orientation (quaternion) x, y, z = position # Decomposing position into x, y, z print('Base link position: [x={:.3f}, y={:.3f}, z={:.3f}]'.format(x, y, z)) euler = euler_from_quat(quaternion) # Converting from quaternion to euler angles roll, pitch, yaw = euler # Decomposing orientation into roll, pitch, yaw print('Base link orientation: [roll={:.3f}, pitch={:.3f}, yaw={:.3f}]'.format(roll, pitch, yaw)) handles.extend(draw_pose(world_from_robot, length=0.5)) # # Draws the base coordinate system (x:RED, y:GREEN, z:BLUE) obstacle_from_robot = multiply(invert(world_from_obstacle), world_from_robot) # Relative transformation from robot to obstacle robot_aabb = get_subtree_aabb(robot, base_link) # Computes the robot's axis-aligned bounding box (AABB) lower, upper = robot_aabb # Decomposing the AABB into the lower and upper extrema center = (lower + upper)/2. # Computing the center of the AABB extent = upper - lower # Computing the dimensions of the AABB handles.extend(draw_point(center)) handles.extend(draw_aabb(robot_aabb)) collision = pairwise_collision(robot, obstacle) # Checks whether robot is currently colliding with obstacle print('Collision: {}'.format(collision)) wait_for_duration(1.0) # Like sleep() but also updates the viewer wait_if_gui() # Like raw_input() but also updates the viewer # Destroys the pybullet world disconnect() if __name__ == '__main__': main()
5,622
Python
55.797979
134
0.672714
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_pr2_motion.py
#!/usr/bin/env python import os import sys import pybullet as p sys.path.append('..') from pybullet_tools.pr2_utils import TOP_HOLDING_LEFT_ARM, PR2_URDF, DRAKE_PR2_URDF, \ SIDE_HOLDING_LEFT_ARM, PR2_GROUPS, open_arm, get_disabled_collisions, REST_LEFT_ARM, rightarm_from_leftarm from pybullet_tools.utils import set_base_values, joint_from_name, quat_from_euler, set_joint_position, \ set_joint_positions, add_data_path, connect, plan_base_motion, plan_joint_motion, enable_gravity, \ joint_controller, dump_body, load_model, joints_from_names, wait_if_gui, disconnect, get_joint_positions, \ get_link_pose, link_from_name, HideOutput, get_pose, wait_if_gui, load_pybullet, set_quat, Euler, PI, RED, add_line, \ wait_for_duration, LockRenderer # TODO: consider making this a function SLEEP = None # None | 0.05 def test_base_motion(pr2, base_start, base_goal, obstacles=[]): #disabled_collisions = get_disabled_collisions(pr2) set_base_values(pr2, base_start) wait_if_gui('Plan Base?') base_limits = ((-2.5, -2.5), (2.5, 2.5)) with LockRenderer(lock=False): base_path = plan_base_motion(pr2, base_goal, base_limits, obstacles=obstacles) if base_path is None: print('Unable to find a base path') return print(len(base_path)) for bq in base_path: set_base_values(pr2, bq) if SLEEP is None: wait_if_gui('Continue?') else: wait_for_duration(SLEEP) def test_drake_base_motion(pr2, base_start, base_goal, obstacles=[]): # TODO: combine this with test_arm_motion """ Drake's PR2 URDF has explicit base joints """ disabled_collisions = get_disabled_collisions(pr2) base_joints = [joint_from_name(pr2, name) for name in PR2_GROUPS['base']] set_joint_positions(pr2, base_joints, base_start) base_joints = base_joints[:2] base_goal = base_goal[:len(base_joints)] wait_if_gui('Plan Base?') with LockRenderer(lock=False): base_path = plan_joint_motion(pr2, base_joints, base_goal, obstacles=obstacles, disabled_collisions=disabled_collisions) if base_path is None: print('Unable to find a base path') return print(len(base_path)) for bq in base_path: set_joint_positions(pr2, base_joints, bq) if SLEEP is None: wait_if_gui('Continue?') else: wait_for_duration(SLEEP) ##################################### def test_arm_motion(pr2, left_joints, arm_goal): disabled_collisions = get_disabled_collisions(pr2) wait_if_gui('Plan Arm?') with LockRenderer(lock=False): arm_path = plan_joint_motion(pr2, left_joints, arm_goal, disabled_collisions=disabled_collisions) if arm_path is None: print('Unable to find an arm path') return print(len(arm_path)) for q in arm_path: set_joint_positions(pr2, left_joints, q) #wait_if_gui('Continue?') wait_for_duration(0.01) def test_arm_control(pr2, left_joints, arm_start): wait_if_gui('Control Arm?') real_time = False enable_gravity() p.setRealTimeSimulation(real_time) for _ in joint_controller(pr2, left_joints, arm_start): if not real_time: p.stepSimulation() #wait_for_duration(0.01) ##################################### def test_ikfast(pr2): from pybullet_tools.ikfast.pr2.ik import get_tool_pose, get_ik_generator left_joints = joints_from_names(pr2, PR2_GROUPS['left_arm']) #right_joints = joints_from_names(pr2, PR2_GROUPS['right_arm']) torso_joints = joints_from_names(pr2, PR2_GROUPS['torso']) torso_left = torso_joints + left_joints print(get_link_pose(pr2, link_from_name(pr2, 'l_gripper_tool_frame'))) # print(forward_kinematics('left', get_joint_positions(pr2, torso_left))) print(get_tool_pose(pr2, 'left')) arm = 'left' pose = get_tool_pose(pr2, arm) generator = get_ik_generator(pr2, arm, pose, torso_limits=False) for i in range(100): solutions = next(generator) print(i, len(solutions)) for q in solutions: set_joint_positions(pr2, torso_left, q) wait_if_gui() ##################################### def main(use_pr2_drake=True): connect(use_gui=True) add_data_path() plane = p.loadURDF("plane.urdf") directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) add_data_path(directory) table_path = "models/table_collision/table.urdf" table = load_pybullet(table_path, fixed_base=True) set_quat(table, quat_from_euler(Euler(yaw=PI/2))) # table/table.urdf, table_square/table_square.urdf, cube.urdf, block.urdf, door.urdf obstacles = [plane, table] pr2_urdf = DRAKE_PR2_URDF if use_pr2_drake else PR2_URDF with HideOutput(): pr2 = load_model(pr2_urdf, fixed_base=True) # TODO: suppress warnings? dump_body(pr2) base_start = (-2, -2, 0) base_goal = (2, 2, 0) arm_start = SIDE_HOLDING_LEFT_ARM #arm_start = TOP_HOLDING_LEFT_ARM #arm_start = REST_LEFT_ARM arm_goal = TOP_HOLDING_LEFT_ARM #arm_goal = SIDE_HOLDING_LEFT_ARM left_joints = joints_from_names(pr2, PR2_GROUPS['left_arm']) right_joints = joints_from_names(pr2, PR2_GROUPS['right_arm']) torso_joints = joints_from_names(pr2, PR2_GROUPS['torso']) set_joint_positions(pr2, left_joints, arm_start) set_joint_positions(pr2, right_joints, rightarm_from_leftarm(REST_LEFT_ARM)) set_joint_positions(pr2, torso_joints, [0.2]) open_arm(pr2, 'left') add_line(base_start, base_goal, color=RED) print(base_start, base_goal) if use_pr2_drake: test_drake_base_motion(pr2, base_start, base_goal, obstacles=obstacles) else: test_base_motion(pr2, base_start, base_goal, obstacles=obstacles) test_arm_motion(pr2, left_joints, arm_goal) # test_arm_control(pr2, left_joints, arm_start) test_ikfast(pr2) wait_if_gui('Finish?') disconnect() if __name__ == '__main__': main()
6,062
Python
35.745454
122
0.639888
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_hsr.py
#!/usr/bin/env python import os import sys import numpy as np import pybullet as p sys.path.append('..') from pybullet_tools.hsrb_utils import TOP_HOLDING_ARM, SIDE_HOLDING_ARM, HSRB_URDF, \ HSR_GROUPS, open_arm, get_disabled_collisions from pybullet_tools.utils import set_base_values, joint_from_name, quat_from_euler, set_joint_position, \ set_joint_positions, add_data_path, connect, plan_base_motion, plan_joint_motion, enable_gravity, \ joint_controller, dump_body, load_model, joints_from_names, wait_if_gui, disconnect, get_joint_positions, \ get_link_pose, link_from_name, get_pose, wait_if_gui, load_pybullet, set_quat, Euler, PI, RED, add_line, \ wait_for_duration, LockRenderer, HideOutput SLEEP = None def test_base_motion(hsr, base_start, base_goal, obstacles=[]): #disabled_collisions = get_disabled_collisions(hsr) set_base_values(hsr, base_start) wait_if_gui('Plan Base?') base_limits = ((-2.5, -2.5), (2.5, 2.5)) with LockRenderer(lock=False): base_path = plan_base_motion(hsr, base_goal, base_limits, obstacles=obstacles) if base_path is None: print('Unable to find a base path') return print(len(base_path)) for bq in base_path: set_base_values(hsr, bq) if SLEEP is None: wait_if_gui('Continue?') else: wait_for_duration(SLEEP) ##################################### def test_arm_motion(hsr, arm_joints, arm_goal): disabled_collisions = get_disabled_collisions(hsr) wait_if_gui('Plan Arm?') with LockRenderer(lock=False): arm_path = plan_joint_motion(hsr, arm_joints, arm_goal, disabled_collisions=disabled_collisions) if arm_path is None: print('Unable to find an arm path') return print(len(arm_path)) for q in arm_path: set_joint_positions(hsr, arm_joints, q) wait_for_duration(0.01) def test_arm_control(hsr, arm_joints, arm_start): wait_if_gui('Control Arm?') real_time = False enable_gravity() p.setRealTimeSimulation(real_time) for _ in joint_controller(hsr, arm_joints, arm_start): if not real_time: p.stepSimulation() ##################################### def test_ikfast(hsr): from pybullet_tools.ikfast.hsrb.ik import get_tool_pose, get_ikfast_generator, hsr_inverse_kinematics arm_joints = joints_from_names(hsr, HSR_GROUPS['arm']) base_joints = joints_from_names(hsr, HSR_GROUPS['base']) base_arm_joints = base_joints + arm_joints arm = 'arm' pose = get_tool_pose(hsr, arm) print('get_link_pose: ', get_link_pose(hsr, link_from_name(hsr, 'hand_palm_link'))) print('get_tool_pose: ', pose) for i in range(100): pose_x = 2.5 pose_y = 2.0 pose_z = 0.5 rotation = np.random.choice(['foward', 'back', 'right', 'left']) if rotation == 'foward': angle = ([0.707107, 0.0, 0.707107, 0.0]) elif rotation == 'back': angle = ([0.0, -0.70710678, 0.0, 0.70710678]) elif rotation == 'right': angle = ([0.5, -0.5, 0.5, 0.5]) elif rotation == 'left': angle = ([0.5, 0.5, 0.5, -0.5]) tool_pose = ((pose_x, pose_y, pose_z), angle) ik_poses = hsr_inverse_kinematics(hsr, arm, tool_pose) if ik_poses != None: set_joint_positions(hsr, base_arm_joints, ik_poses) ee_pose = get_tool_pose(hsr, arm) print("ee_pose:", ee_pose) wait_if_gui() ##################################### def main(): connect(use_gui=True) add_data_path() plane = p.loadURDF("plane.urdf") directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) add_data_path(directory) table_path = "models/table_collision/table.urdf" table = load_pybullet(table_path, fixed_base=True) set_quat(table, quat_from_euler(Euler(yaw=PI/2))) obstacles = [table] hsr_urdf = HSRB_URDF with HideOutput(): hsr = load_model(hsr_urdf, fixed_base=True) dump_body(hsr) base_start = (-2, -2, 0) base_goal = (2, 2, 0) arm_start = SIDE_HOLDING_ARM arm_goal = TOP_HOLDING_ARM arm_joints = joints_from_names(hsr, HSR_GROUPS['arm']) torso_joints = joints_from_names(hsr, HSR_GROUPS['torso']) gripper_joints = joints_from_names(hsr, HSR_GROUPS['gripper']) print('Set joints') set_joint_positions(hsr, arm_joints, arm_start) set_joint_positions(hsr, torso_joints, [0.0]) set_joint_positions(hsr, gripper_joints, [0, 0]) add_line(base_start, base_goal, color=RED) print(base_start, base_goal) print('Test base motion') test_base_motion(hsr, base_start, base_goal, obstacles=obstacles) print('Test arm motion') test_arm_motion(hsr, arm_joints, arm_goal) test_ikfast(hsr) while True: word = input('Input something: ') if word == 'Finish': disconnect() break if __name__ == '__main__': main()
4,985
Python
32.24
111
0.608826
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_visibility.py
#!/usr/bin/env python from __future__ import print_function import pybullet as p from pybullet_tools.pr2_utils import HEAD_LINK_NAME, PR2_GROUPS, get_viewcone, get_detections, \ REST_LEFT_ARM, rightarm_from_leftarm, inverse_visibility, get_detection_cone, visible_base_generator, \ DRAKE_PR2_URDF from pybullet_tools.utils import joint_from_name, set_joint_position, disconnect, HideOutput, \ set_joint_positions, connect, wait_if_gui, get_link_pose, link_from_name, set_point, set_pose, \ dump_body, load_model, create_mesh, point_from_pose, get_pose, joints_from_names, BLOCK_URDF, \ remove_body, child_link_from_joint, RED, BLUE, get_link_name, add_line, draw_point def main(): # TODO: update this example connect(use_gui=True) with HideOutput(): pr2 = load_model(DRAKE_PR2_URDF) set_joint_positions(pr2, joints_from_names(pr2, PR2_GROUPS['left_arm']), REST_LEFT_ARM) set_joint_positions(pr2, joints_from_names(pr2, PR2_GROUPS['right_arm']), rightarm_from_leftarm(REST_LEFT_ARM)) set_joint_positions(pr2, joints_from_names(pr2, PR2_GROUPS['torso']), [0.2]) dump_body(pr2) block = load_model(BLOCK_URDF, fixed_base=False) set_point(block, [2, 0.5, 1]) target_point = point_from_pose(get_pose(block)) draw_point(target_point) head_joints = joints_from_names(pr2, PR2_GROUPS['head']) #head_link = child_link_from_joint(head_joints[-1]) #head_name = get_link_name(pr2, head_link) head_name = 'high_def_optical_frame' # HEAD_LINK_NAME | high_def_optical_frame | high_def_frame head_link = link_from_name(pr2, head_name) #max_detect_distance = 2.5 max_register_distance = 1.0 distance_range = (max_register_distance/2, max_register_distance) base_generator = visible_base_generator(pr2, target_point, distance_range) base_joints = joints_from_names(pr2, PR2_GROUPS['base']) for i in range(5): base_conf = next(base_generator) set_joint_positions(pr2, base_joints, base_conf) handles = [ add_line(point_from_pose(get_link_pose(pr2, head_link)), target_point, color=RED), add_line(point_from_pose(get_link_pose(pr2, link_from_name(pr2, HEAD_LINK_NAME))), target_point, color=BLUE), ] # head_conf = sub_inverse_kinematics(pr2, head_joints[0], HEAD_LINK, ) head_conf = inverse_visibility(pr2, target_point, head_name=head_name, head_joints=head_joints) assert head_conf is not None set_joint_positions(pr2, head_joints, head_conf) print(get_detections(pr2)) # TODO: does this detect the robot sometimes? detect_mesh, z = get_detection_cone(pr2, block) detect_cone = create_mesh(detect_mesh, color=(0, 1, 0, 0.5)) set_pose(detect_cone, get_link_pose(pr2, link_from_name(pr2, HEAD_LINK_NAME))) view_cone = get_viewcone(depth=2.5, color=(1, 0, 0, 0.25)) set_pose(view_cone, get_link_pose(pr2, link_from_name(pr2, HEAD_LINK_NAME))) wait_if_gui() remove_body(detect_cone) remove_body(view_cone) disconnect() if __name__ == '__main__': main()
3,137
Python
41.986301
121
0.664967
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_kiva.py
#!/usr/bin/env python from __future__ import print_function import argparse import os from pybullet_tools.pr2_problems import create_floor from pybullet_tools.utils import connect, disconnect, wait_for_user, LockRenderer, stable_z, \ load_model, ROOMBA_URDF, \ HideOutput, set_point, Point, load_pybullet, get_model_path, set_color, get_all_links, \ KIVA_SHELF_SDF, add_data_path, draw_pose, unit_pose, dump_body # TODO: Kiva robot # TODO: stow, pick, and recharge stations ORANGE = (1, 0.5, 0, 1) def main(): # TODO: move to pybullet-planning for now parser = argparse.ArgumentParser() parser.add_argument('-viewer', action='store_true', help='enable the viewer while planning') args = parser.parse_args() print(args) connect(use_gui=True) with LockRenderer(): draw_pose(unit_pose(), length=1) floor = create_floor() with HideOutput(): robot = load_pybullet(get_model_path(ROOMBA_URDF), fixed_base=True, scale=2.0) for link in get_all_links(robot): set_color(robot, link=link, color=ORANGE) robot_z = stable_z(robot, floor) set_point(robot, Point(z=robot_z)) #set_base_conf(robot, rover_confs[i]) data_path = add_data_path() shelf, = load_model(os.path.join(data_path, KIVA_SHELF_SDF), fixed_base=True) # TODO: returns a tuple dump_body(shelf) #draw_aabb(get_aabb(shelf)) wait_for_user() disconnect() if __name__ == '__main__': main()
1,526
Python
30.812499
109
0.639581
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/test_water.py
#!/usr/bin/env python from __future__ import print_function import time import numpy as np from pybullet_tools.utils import add_data_path, connect, enable_gravity, wait_if_gui, disconnect, create_sphere, set_point, Point, \ enable_real_time, dump_world, load_model, wait_if_gui, set_camera, stable_z, \ set_color, get_lower_upper, wait_for_duration, simulate_for_duration, load_pybullet, \ safe_zip, HideOutput, draw_global_system def main(): connect(use_gui=True) add_data_path() draw_global_system() set_camera(0, -30, 1) with HideOutput(): plane = load_pybullet('plane.urdf', fixed_base=True) #plane = load_model('plane.urdf') cup = load_model('models/cup.urdf', fixed_base=True) #set_point(cup, Point(z=stable_z(cup, plane))) set_point(cup, Point(z=.2)) set_color(cup, (1, 0, 0, .4)) num_droplets = 100 #radius = 0.025 #radius = 0.005 radius = 0.0025 # TODO: more efficient ways to make all of these droplets = [create_sphere(radius, mass=0.01) for _ in range(num_droplets)] # kg cup_thickness = 0.001 lower, upper = get_lower_upper(cup) print(lower, upper) buffer = cup_thickness + radius lower = np.array(lower) + buffer*np.ones(len(lower)) upper = np.array(upper) - buffer*np.ones(len(upper)) limits = safe_zip(lower, upper) x_range, y_range = limits[:2] z = upper[2] + 0.1 #x_range = [-1, 1] #y_range = [-1, 1] #z = 1 for droplet in droplets: x = np.random.uniform(*x_range) y = np.random.uniform(*y_range) set_point(droplet, Point(x, y, z)) for i, droplet in enumerate(droplets): x, y = np.random.normal(0, 1e-3, 2) set_point(droplet, Point(x, y, z+i*(2*radius+1e-3))) #dump_world() wait_if_gui() #wait_if_gui('Start?') enable_gravity() simulate_for_duration(5.0) # enable_real_time() # try: # while True: # enable_gravity() # enable_real_time requires a command # #time.sleep(dt) # except KeyboardInterrupt: # pass # print() #time.sleep(1.0) wait_if_gui('Finish?') disconnect() if __name__ == '__main__': main()
2,215
Python
27.77922
132
0.602257
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/gripper/test_side.py
#!/usr/bin/env python from __future__ import print_function import argparse import os import numpy as np from pybullet_tools.pr2_problems import create_floor, create_table from pybullet_tools.pr2_utils import get_top_grasps, get_side_grasps from pybullet_tools.utils import connect, get_pose, set_pose, Point, disconnect, HideOutput, \ wait_for_user, load_pybullet, WSG_50_URDF, get_model_path, draw_pose, \ link_from_name, get_max_limit, get_movable_joints, set_joint_position, unit_pose, create_box, RED, set_point, \ stable_z, set_camera_pose, LockRenderer, add_line, multiply, invert, get_relative_pose, GREEN, BLUE, TAN, Euler, Pose from .test_top import EPSILON, TABLE_WIDTH, BLOCK_SIDE, open_gripper # TODO: NAMO def main(): parser = argparse.ArgumentParser() # Automatically includes help parser.add_argument('-viewer', action='store_true', help='enable viewer.') args = parser.parse_args() connect(use_gui=True) with LockRenderer(): draw_pose(unit_pose(), length=1, width=1) floor = create_floor() set_point(floor, Point(z=-EPSILON)) table1 = create_table(width=TABLE_WIDTH, length=TABLE_WIDTH/2, height=TABLE_WIDTH/2, top_color=TAN, cylinder=False) set_point(table1, Point(y=+0.5)) table2 = create_table(width=TABLE_WIDTH, length=TABLE_WIDTH/2, height=TABLE_WIDTH/2, top_color=TAN, cylinder=False) set_point(table2, Point(y=-0.5)) tables = [table1, table2] #set_euler(table1, Euler(yaw=np.pi/2)) with HideOutput(): # data_path = add_data_path() # robot_path = os.path.join(data_path, WSG_GRIPPER) robot_path = get_model_path(WSG_50_URDF) # WSG_50_URDF | PANDA_HAND_URDF robot = load_pybullet(robot_path, fixed_base=True) #dump_body(robot) block1 = create_box(w=BLOCK_SIDE, l=BLOCK_SIDE, h=BLOCK_SIDE, color=RED) block_z = stable_z(block1, table1) set_point(block1, Point(y=-0.5, z=block_z)) block2 = create_box(w=BLOCK_SIDE, l=BLOCK_SIDE, h=BLOCK_SIDE, color=GREEN) set_point(block2, Point(x=-0.25, y=-0.5, z=block_z)) block3 = create_box(w=BLOCK_SIDE, l=BLOCK_SIDE, h=BLOCK_SIDE, color=BLUE) set_point(block3, Point(x=-0.15, y=+0.5, z=block_z)) blocks = [block1, block2, block3] set_camera_pose(camera_point=Point(x=-1, z=block_z+1), target_point=Point(z=block_z)) block_pose = get_pose(block1) open_gripper(robot) tool_link = link_from_name(robot, 'tool_link') base_from_tool = get_relative_pose(robot, tool_link) #draw_pose(unit_pose(), parent=robot, parent_link=tool_link) grasps = get_side_grasps(block1, tool_pose=Pose(euler=Euler(yaw=np.pi/2)), top_offset=0.02, grasp_length=0.03, under=False)[1:2] for grasp in grasps: gripper_pose = multiply(block_pose, invert(grasp)) set_pose(robot, multiply(gripper_pose, invert(base_from_tool))) wait_for_user() wait_for_user('Finish?') disconnect() if __name__ == '__main__': main()
3,158
Python
38.4875
121
0.635212
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/examples/gripper/test_top.py
#!/usr/bin/env python from __future__ import print_function import argparse import os from pybullet_tools.pr2_problems import create_floor, create_table from pybullet_tools.pr2_utils import get_top_grasps from pybullet_tools.utils import connect, get_pose, set_pose, Point, disconnect, HideOutput, \ wait_for_user, load_pybullet, WSG_50_URDF, get_model_path, draw_pose, \ link_from_name, get_max_limit, get_movable_joints, set_joint_position, unit_pose, create_box, RED, set_point, \ stable_z, set_camera_pose, LockRenderer, add_line, multiply, invert, get_relative_pose, GREEN, BLUE, TAN, create_cylinder #from hsr_tamp.pddlstream.utils import get_file_path # https://www.generationrobots.com/en/403318-fe-gripper-for-panda-robotic-arm.html # /usr/local/lib/python2.7/site-packages/pybullet_data/gripper/ # drake/manipulation/models/ycb/sdf/005_tomato_soup_can.sdf def close_gripper(robot): for joint in get_movable_joints(robot): set_joint_position(robot, joint, get_max_limit(robot, joint)) def open_gripper(robot): for joint in get_movable_joints(robot): set_joint_position(robot, joint, get_max_limit(robot, joint)) BLOCK_SIDE = 0.07 TABLE_WIDTH = 1.0 EPSILON = 1e-3 DRAKE_PATH = '/Users/caelan/Programs/external/drake' DRAKE_YCB = 'manipulation/models/ycb/sdf/003_cracker_box.sdf' YCB_PATH = '/Users/caelan/Programs/external/ycb_benchmarks/16k_laser_scan' YCB_TEMPLATE = '{}/google_16k/textured.obj' def main(): parser = argparse.ArgumentParser() # Automatically includes help parser.add_argument('-viewer', action='store_true', help='enable viewer.') args = parser.parse_args() connect(use_gui=True) #ycb_path = os.path.join(DRAKE_PATH, DRAKE_YCB) #ycb_path = os.path.join(YCB_PATH, YCB_TEMPLATE.format('003_cracker_box')) #print(ycb_path) #load_pybullet(ycb_path) with LockRenderer(): draw_pose(unit_pose(), length=1, width=1) floor = create_floor() set_point(floor, Point(z=-EPSILON)) table = create_table(width=TABLE_WIDTH, length=TABLE_WIDTH/2, height=TABLE_WIDTH/2, top_color=TAN, cylinder=False) #set_euler(table, Euler(yaw=np.pi/2)) with HideOutput(False): # data_path = add_data_path() # robot_path = os.path.join(data_path, WSG_GRIPPER) robot_path = get_model_path(WSG_50_URDF) # WSG_50_URDF | PANDA_HAND_URDF #robot_path = get_file_path(__file__, 'mit_arch_suction_gripper/mit_arch_suction_gripper.urdf') robot = load_pybullet(robot_path, fixed_base=True) #dump_body(robot) #robot = create_cylinder(radius=0.5*BLOCK_SIDE, height=4*BLOCK_SIDE) # vacuum gripper block1 = create_box(w=BLOCK_SIDE, l=BLOCK_SIDE, h=BLOCK_SIDE, color=RED) block_z = stable_z(block1, table) set_point(block1, Point(z=block_z)) block2 = create_box(w=BLOCK_SIDE, l=BLOCK_SIDE, h=BLOCK_SIDE, color=GREEN) set_point(block2, Point(x=+0.25, z=block_z)) block3 = create_box(w=BLOCK_SIDE, l=BLOCK_SIDE, h=BLOCK_SIDE, color=BLUE) set_point(block3, Point(x=-0.15, z=block_z)) blocks = [block1, block2, block3] add_line(Point(x=-TABLE_WIDTH/2, z=block_z - BLOCK_SIDE/2 + EPSILON), Point(x=+TABLE_WIDTH/2, z=block_z - BLOCK_SIDE/2 + EPSILON), color=RED) set_camera_pose(camera_point=Point(y=-1, z=block_z+1), target_point=Point(z=block_z)) wait_for_user() block_pose = get_pose(block1) open_gripper(robot) tool_link = link_from_name(robot, 'tool_link') base_from_tool = get_relative_pose(robot, tool_link) #draw_pose(unit_pose(), parent=robot, parent_link=tool_link) y_grasp, x_grasp = get_top_grasps(block1, tool_pose=unit_pose(), grasp_length=0.03, under=False) grasp = y_grasp # fingers won't collide gripper_pose = multiply(block_pose, invert(grasp)) set_pose(robot, multiply(gripper_pose, invert(base_from_tool))) wait_for_user('Finish?') disconnect() if __name__ == '__main__': main()
4,046
Python
41.6
125
0.671775
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/movo_constants.py
#!/usr/bin/env python from __future__ import print_function from itertools import combinations import numpy as np from .ikfast.utils import IKFastInfo from .utils import joints_from_names, has_joint, get_max_limits, get_min_limits, apply_alpha, \ pairwise_link_collision, get_all_links, get_link_name, are_links_adjacent #MOVO_URDF = "models/movo_description/movo.urdf" #MOVO_URDF = "models/movo_description/movo_lis.urdf" #MOVO_URDF = "models/movo_description/movo_robotiq.urdf" MOVO_URDF = "models/movo_description/movo_robotiq_collision.urdf" # https://github.mit.edu/Learning-and-Intelligent-Systems/ltamp_pr2/blob/master/control_tools/ik/ik_tools/movo_ik/movo_robotiq.urdf # https://github.com/Learning-and-Intelligent-Systems/movo_ws/blob/master/src/kinova-movo-bare/movo_common/movo_description/urdf/movo.custom.urdf # https://github.mit.edu/Learning-and-Intelligent-Systems/ltamp_pr2/tree/master/control_tools/ik/ik_tools/movo_ik ##################################### LEFT = 'left' # KG3 RIGHT = 'right' # ROBOTIQ ARMS = [RIGHT, LEFT] BASE_JOINTS = ['x', 'y', 'theta'] TORSO_JOINTS = ['linear_joint'] HEAD_JOINTS = ['pan_joint', 'tilt_joint'] ARM_JOINTS = ['{}_shoulder_pan_joint', '{}_shoulder_lift_joint', '{}_arm_half_joint', '{}_elbow_joint', '{}_wrist_spherical_1_joint', '{}_wrist_spherical_2_joint', '{}_wrist_3_joint'] KG3_GRIPPER_JOINTS = ['{}_gripper_finger1_joint', '{}_gripper_finger2_joint', '{}_gripper_finger3_joint'] ROBOTIQ_GRIPPER_JOINTS = ['{}_gripper_finger1_joint', '{}_gripper_finger2_joint', '{}_gripper_finger1_inner_knuckle_joint', '{}_gripper_finger1_finger_tip_joint', '{}_gripper_finger2_inner_knuckle_joint', '{}_gripper_finger2_finger_tip_joint'] EE_LINK = '{}_ee_link' TOOL_LINK = '{}_tool_link' #PASSIVE_JOINTS = ['mid_body_joint'] # TODO: mid_body_joint - might be passive # https://github.com/Kinovarobotics/kinova-movo/blob/master/movo_moveit_config/config/movo_kg2.srdf # https://github.mit.edu/Learning-and-Intelligent-Systems/ltamp_pr2/blob/master/control_tools/ik/ik_tools/movo_ik/movo_ik_generator.py MOVO_INFOS = { arm: IKFastInfo(module_name='movo.movo_{}_arm_ik'.format(arm), base_link='base_link', ee_link=EE_LINK.format(arm), free_joints=['linear_joint', '{}_arm_half_joint'.format(arm)]) for arm in ARMS} MOVO_COLOR = apply_alpha(0.25*np.ones(3), 1) ##################################### def names_from_templates(templates, *args): return [template.format(*args) for template in templates] def get_arm_joints(robot, arm): assert arm in ARMS return joints_from_names(robot, names_from_templates(ARM_JOINTS, arm)) def has_kg3_gripper(robot, arm): assert arm in ARMS return all(has_joint(robot, joint_name) for joint_name in names_from_templates(KG3_GRIPPER_JOINTS, arm)) def has_robotiq_gripper(robot, arm): assert arm in ARMS return all(has_joint(robot, joint_name) for joint_name in names_from_templates(ROBOTIQ_GRIPPER_JOINTS, arm)) def get_gripper_joints(robot, arm): assert arm in ARMS if has_kg3_gripper(robot, arm): return joints_from_names(robot, names_from_templates(KG3_GRIPPER_JOINTS, arm)) elif has_robotiq_gripper(robot, arm): return joints_from_names(robot, names_from_templates(ROBOTIQ_GRIPPER_JOINTS, arm)) raise ValueError(arm) def get_open_positions(robot, arm): assert arm in ARMS joints = get_gripper_joints(robot, arm) if has_kg3_gripper(robot, arm): return get_min_limits(robot, joints) elif has_robotiq_gripper(robot, arm): return 6 * [0.] raise ValueError(arm) def get_closed_positions(robot, arm): assert arm in ARMS joints = get_gripper_joints(robot, arm) if has_kg3_gripper(robot, arm): return get_max_limits(robot, joints) elif has_robotiq_gripper(robot, arm): return [0.32]*6 raise ValueError(arm) ##################################### def get_colliding(robot): disabled = [] for link1, link2 in combinations(get_all_links(robot), r=2): if not are_links_adjacent(robot, link1, link2) and pairwise_link_collision(robot, link1, robot, link2): disabled.append((get_link_name(robot, link1), get_link_name(robot, link2))) return disabled NEVER_COLLISIONS = [ ('linear_actuator_fixed_link', 'right_base_link'), ('linear_actuator_fixed_link', 'right_shoulder_link'), ('linear_actuator_fixed_link', 'left_base_link'), ('linear_actuator_fixed_link', 'left_shoulder_link'), ('linear_actuator_fixed_link', 'front_laser_link'), ('linear_actuator_fixed_link', 'rear_laser_link'), ('linear_actuator_link', 'pan_link'), ('linear_actuator_link', 'right_shoulder_link'), ('linear_actuator_link', 'right_arm_half_1_link'), ('linear_actuator_link', 'left_shoulder_link'), ('linear_actuator_link', 'left_arm_half_1_link'), ('right_wrist_spherical_2_link', 'right_robotiq_coupler_link'), ('right_wrist_3_link', 'right_robotiq_coupler_link'), ('right_wrist_3_link', 'right_gripper_base_link'), ('right_gripper_finger1_finger_link', 'right_gripper_finger1_finger_tip_link'), ('right_gripper_finger2_finger_link', 'right_gripper_finger2_finger_tip_link'), ('left_wrist_spherical_2_link', 'left_gripper_base_link'), ('left_wrist_3_link', 'left_gripper_base_link'), ]
5,348
Python
43.949579
145
0.678571
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/hsrb_utils.py
import os import re import math import random import numpy as np from itertools import combinations from collections import namedtuple from .utils import multiply, get_link_pose, set_joint_position, set_joint_positions, get_joint_positions, get_min_limit, get_max_limit, quat_from_euler, read_pickle, set_pose, \ get_pose, euler_from_quat, link_from_name, point_from_pose, invert, Pose, \ unit_pose, joints_from_names, PoseSaver, get_aabb, get_joint_limits, ConfSaver, get_bodies, create_mesh, remove_body, \ unit_from_theta, violates_limit, \ violates_limits, add_line, get_body_name, get_num_joints, approximate_as_cylinder, \ approximate_as_prism, unit_quat, unit_point, angle_between, quat_from_pose, compute_jacobian, \ movable_from_joints, quat_from_axis_angle, LockRenderer, Euler, get_links, get_link_name, \ get_extend_fn, get_moving_links, link_pairs_collision, get_link_subtree, \ clone_body, get_all_links, pairwise_collision, tform_point, get_camera_matrix, ray_from_pixel, pixel_from_ray, dimensions_from_camera_matrix, \ wrap_angle, TRANSPARENT, PI, OOBB, pixel_from_point, set_all_color, wait_if_gui from .hsrb_never_collisions import NEVER_COLLISIONS ARM = 'arm' ARM_NAMES = (ARM) ##################################### HSR_GROUPS = { 'base': ['joint_x', 'joint_y', 'joint_rz'], 'torso': ['torso_lift_joint'], 'head': ['head_pan_joint', 'head_tilt_joint'], 'arm': ['arm_lift_joint', 'arm_flex_joint', 'arm_roll_joint', 'wrist_flex_joint', 'wrist_roll_joint'], 'gripper': ['hand_l_proximal_joint', 'hand_r_proximal_joint'], 'gripper_passive': ['hand_l_distal_joint', 'hand_r_distal_joint'] } HSR_TOOL_FRAMES = {ARM: 'hand_palm_link'} HSR_GRIPPER_ROOTS = {ARM: 'hand_palm_link'} HSR_BASE_LINK = 'base_footprint' HEAD_LINK_NAME = 'high_def_optical_frame' # Arm tool poses TOOL_POSE = Pose(euler=Euler(pitch=np.pi/2)) ##################################### # Special configurations TOP_HOLDING_ARM = [0.1, -PI/2, 0.0, -PI/2, 0.0] SIDE_HOLDING_ARM = [0.1, -PI/2, 0.0, 0.0, 0.0] # [0.1, -PI/8, 0.0, -PI/8, 1.0] BOTTOM_HOLDING_AMR = [0.1, -PI/2, 0.0, 0.0, -PI/2] HSR_CARRY_CONFS = { 'top': TOP_HOLDING_ARM, 'side': SIDE_HOLDING_ARM, 'bottom': BOTTOM_HOLDING_AMR } ##################################### HSRB_URDF = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'models/hsrb_description/robots/hsrb.urdf') ##################################### def get_base_pose(hsr): return get_link_pose(hsr, link_from_name(hsr, HSR_BASE_LINK)) def arm_conf(arm, arm_config): if arm == ARM: return arm_config def base_conf(arm, base_config): if arm == ARM: return base_config def base_arm_conf(arm, base_config, arm_config): base_arm_conf = [] if arm == ARM: for base in base_config: base_arm_conf.append(base) for arm in arm_config: base_arm_conf.append(arm) return base_arm_conf def get_carry_conf(arm, grasp_type): return arm_conf(arm, HSR_CARRY_CONFS[grasp_type]) def get_other_arm(arm): for other_arm in ARM_NAMES: if other_arm != arm: return other_arm raise ValueError(arm) ##################################### def get_disabled_collisions(hsr): disabled_names = NEVER_COLLISIONS link_mapping = {get_link_name(hsr, link): link for link in get_links(hsr)} return {(link_mapping[name1], link_mapping[name2]) for name1, name2 in disabled_names if (name1 in link_mapping) and (name2 in link_mapping)} def load_dae_collisions(): dae_file = 'models/hsr_description/hsr-beta-static.dae' dae_string = open(dae_file).read() link_regex = r'<\s*link\s+sid="(\w+)"\s+name="(\w+)"\s*>' link_mapping = dict(re.findall(link_regex, dae_string)) ignore_regex = r'<\s*ignore_link_pair\s+link0="kmodel1/(\w+)"\s+link1="kmodel1/(\w+)"\s*/>' disabled_collisions = [] for link1, link2 in re.findall(ignore_regex, dae_string): disabled_collisions.append((link_mapping[link1], link_mapping[link2])) return disabled_collisions def load_srdf_collisions(): srdf_file = 'models/hsrb_description/hsrb4s.srdf' srdf_string = open(srdf_file).read() regex = r'<\s*disable_collisions\s+link1="(\w+)"\s+link2="(\w+)"\s+reason="(\w+)"\s*/>' disabled_collisions = [] for link1, link2, reason in re.findall(regex, srdf_string): if reason == 'Never': disabled_collisions.append((link1, link2)) return disabled_collisions ##################################### def get_groups(): return sorted(HSR_GROUPS) def get_group_joints(robot, group): return joints_from_names(robot, HSR_GROUPS[group]) def get_group_conf(robot, group): return get_joint_positions(robot, get_group_joints(robot, group)) def set_group_conf(robot, group, positions): set_joint_positions(robot, get_group_joints(robot, group), positions) def set_group_positions(robot, group_positions): for group, positions in group_positions.items(): set_group_conf(robot, group, positions) def get_group_positions(robot): return {group: get_group_conf(robot, group) for group in get_groups()} ##################################### # End-effectors def get_arm_joints(robot, arm): return get_group_joints(robot, arm) def get_base_joints(robot, arm): return joints_from_names(robot, HSR_GROUPS['base']) def get_torso_joints(robot, arm): return joints_from_names(robot, HSR_GROUPS['torso']) def get_torso_arm_joints(robot, arm): return joints_from_names(robot, HSR_GROUPS['torso'] + HSR_GROUPS[arm]) def get_base_arm_joints(robot, arm): return joints_from_names(robot, HSR_GROUPS['base'] + HSR_GROUPS[arm]) def get_base_torso_joints(robot): return joints_from_names(robot, HSR_GROUPS['base'] + HSR_GROUPS['torso']) def get_base_torso_arm_joints(robot): return joints_from_names(robot, HSR_GROUPS['base'] + HSR_GROUPS['torso'] + HSR_GROUPS['arm']) def set_arm_conf(robot, arm, conf): set_joint_positions(robot, get_arm_joints(robot, arm), conf) def get_gripper_link(robot, arm): return link_from_name(robot, HSR_TOOL_FRAMES[arm]) def get_gripper_joints(robot, arm): return get_group_joints(robot, 'gripper') def set_gripper_position(robot, arm, position): gripper_joints = get_gripper_joints(robot, arm) set_joint_positions(robot, gripper_joints, [position] * len(gripper_joints)) def open_arm(robot, arm): for joint in get_gripper_joints(robot, arm): set_joint_position(robot, joint, get_max_limit(robot, joint)) def close_arm(robot, arm): for joint in get_gripper_joints(robot, arm): set_joint_position(robot, joint, get_min_limit(robot, joint)) open_gripper = open_arm close_gripper = close_arm ##################################### # Box grasps GRASP_LENGTH = 0. MAX_GRASP_WIDTH = np.inf SIDE_HEIGHT_OFFSET = 0.03 def get_top_grasps(body, under=False, tool_pose=TOOL_POSE, body_pose=unit_pose(), max_width=MAX_GRASP_WIDTH, grasp_length=GRASP_LENGTH): center, (w, l, h) = approximate_as_prism(body, body_pose=body_pose) reflect_z = Pose(euler=[0, math.pi, 0]) translate_z = Pose(point=[0, 0, h / 2 - grasp_length]) translate_center = Pose(point=point_from_pose(body_pose)-center) grasps = [] if w <= max_width: for i in range(1 + under): rotate_z = Pose(euler=[0, 0, math.pi / 2 + i * math.pi]) grasps += [multiply(tool_pose, translate_z, rotate_z, reflect_z, translate_center, body_pose)] if l <= max_width: for i in range(1 + under): rotate_z = Pose(euler=[0, 0, i * math.pi]) grasps += [multiply(tool_pose, translate_z, rotate_z, reflect_z, translate_center, body_pose)] return grasps def get_side_grasps(body, under=False, tool_pose=TOOL_POSE, body_pose=unit_pose(), max_width=MAX_GRASP_WIDTH, grasp_length=GRASP_LENGTH, top_offset=SIDE_HEIGHT_OFFSET): center, (w, l, h) = approximate_as_prism(body, body_pose=body_pose) translate_center = Pose(point=point_from_pose(body_pose)-center) grasps = [] x_offset = h / 2 - top_offset for j in range(1 + under): swap_xz = Pose(euler=[0, -math.pi / 2 + j * math.pi, 0]) if w <= max_width: translate_z = Pose(point=[x_offset, 0, l / 2 - grasp_length]) for i in range(2): rotate_z = Pose(euler=[math.pi / 2 + i * math.pi, 0, 0]) grasps += [multiply(tool_pose, translate_z, rotate_z, swap_xz, translate_center, body_pose)] # , np.array([w]) if l <= max_width: translate_z = Pose(point=[x_offset, 0, w / 2 - grasp_length]) for i in range(2): rotate_z = Pose(euler=[i * math.pi, 0, 0]) grasps += [multiply(tool_pose, translate_z, rotate_z, swap_xz, translate_center, body_pose)] # , np.array([l]) return grasps ##################################### # Cylinder grasps def get_top_cylinder_grasps(body, tool_pose=TOOL_POSE, body_pose=unit_pose(), max_width=MAX_GRASP_WIDTH, grasp_length=GRASP_LENGTH): # Apply transformations right to left on object pose center, (diameter, height) = approximate_as_cylinder(body, body_pose=body_pose) reflect_z = Pose(euler=[0, math.pi, 0]) translate_z = Pose(point=[0, 0, height / 2 - grasp_length]) translate_center = Pose(point=point_from_pose(body_pose)-center) if max_width < diameter: return while True: theta = random.uniform(0, 2*np.pi) rotate_z = Pose(euler=[0, 0, theta]) yield multiply(tool_pose, translate_z, rotate_z, reflect_z, translate_center, body_pose) def get_side_cylinder_grasps(body, under=False, tool_pose=TOOL_POSE, body_pose=unit_pose(), max_width=MAX_GRASP_WIDTH, grasp_length=GRASP_LENGTH, top_offset=SIDE_HEIGHT_OFFSET): center, (diameter, height) = approximate_as_cylinder(body, body_pose=body_pose) translate_center = Pose(point_from_pose(body_pose)-center) x_offset = height/2 - top_offset if max_width < diameter: return while True: theta = random.uniform(0, 2*np.pi) translate_rotate = ([x_offset, 0, diameter / 2 - grasp_length], quat_from_euler([theta, 0, 0])) for j in range(1 + under): swap_xz = Pose(euler=[0, -math.pi / 2 + j * math.pi, 0]) yield multiply(tool_pose, translate_rotate, swap_xz, translate_center, body_pose) def get_edge_cylinder_grasps(body, under=False, tool_pose=TOOL_POSE, body_pose=unit_pose(), grasp_length=GRASP_LENGTH): center, (diameter, height) = approximate_as_cylinder(body, body_pose=body_pose) translate_yz = Pose(point=[0, diameter/2, height/2 - grasp_length]) reflect_y = Pose(euler=[0, math.pi, 0]) translate_center = Pose(point=point_from_pose(body_pose)-center) while True: theta = random.uniform(0, 2*np.pi) rotate_z = Pose(euler=[0, 0, theta]) for i in range(1 + under): rotate_under = Pose(euler=[0, 0, i * math.pi]) yield multiply(tool_pose, rotate_under, translate_yz, rotate_z, reflect_y, translate_center, body_pose) ##################################### # Cylinder pushes def get_cylinder_push(body, theta, under=False, body_quat=unit_quat(), tilt=0., base_offset=0.02, side_offset=0.03): body_pose = (unit_point(), body_quat) center, (diameter, height) = approximate_as_cylinder(body, body_pose=body_pose) translate_center = Pose(point=point_from_pose(body_pose)-center) tilt_gripper = Pose(euler=Euler(pitch=tilt)) translate_x = Pose(point=[-diameter / 2 - side_offset, 0, 0]) # Compute as a function of theta translate_z = Pose(point=[0, 0, -height / 2 + base_offset]) rotate_x = Pose(euler=Euler(yaw=theta)) reflect_z = Pose(euler=Euler(pitch=math.pi)) grasps = [] for i in range(1 + under): rotate_z = Pose(euler=Euler(yaw=i * math.pi)) grasps.append(multiply(tilt_gripper, translate_x, translate_z, rotate_x, rotate_z, reflect_z, translate_center, body_pose)) return grasps ##################################### # Button presses PRESS_OFFSET = 0.02 def get_x_presses(body, max_orientations=1, body_pose=unit_pose(), top_offset=PRESS_OFFSET): # gripper_from_object center, (w, _, h) = approximate_as_prism(body, body_pose=body_pose) translate_center = Pose(-center) press_poses = [] for j in range(max_orientations): swap_xz = Pose(euler=[0, -math.pi / 2 + j * math.pi, 0]) translate = Pose(point=[0, 0, w / 2 + top_offset]) press_poses += [multiply(TOOL_POSE, translate, swap_xz, translate_center, body_pose)] return press_poses def get_top_presses(body, tool_pose=TOOL_POSE, body_pose=unit_pose(), top_offset=PRESS_OFFSET, **kwargs): center, (_, height) = approximate_as_cylinder(body, body_pose=body_pose, **kwargs) reflect_z = Pose(euler=[0, math.pi, 0]) translate_z = Pose(point=[0, 0, height / 2 + top_offset]) translate_center = Pose(point=point_from_pose(body_pose)-center) while True: theta = random.uniform(0, 2*np.pi) rotate_z = Pose(euler=[0, 0, theta]) yield multiply(tool_pose, translate_z, rotate_z, reflect_z, translate_center, body_pose) GET_GRASPS = { 'top': get_top_grasps, 'side': get_side_grasps, } ##################################### # Inverse reachability DATABASES_DIR = '../databases' IR_FILENAME = '{}_{}_ir.pickle' IR_CACHE = {} def get_database_file(filename): directory = os.path.dirname(os.path.abspath(__file__)) return os.path.join(directory, DATABASES_DIR, filename) def load_inverse_reachability(arm, grasp_type): key = (arm, grasp_type) if key not in IR_CACHE: filename = IR_FILENAME.format(grasp_type, arm) path = get_database_file(filename) IR_CACHE[key] = read_pickle(path)['gripper_from_base'] return IR_CACHE[key] def learned_forward_generator(robot, base_pose, arm, grasp_type): gripper_from_base_list = list(load_inverse_reachability(arm, grasp_type)) random.shuffle(gripper_from_base_list) for gripper_from_base in gripper_from_base_list: yield multiply(base_pose, invert(gripper_from_base)) def learned_pose_generator(robot, gripper_pose, arm, grasp_type): gripper_from_base_list = load_inverse_reachability(arm, grasp_type) random.shuffle(gripper_from_base_list) for gripper_from_base in gripper_from_base_list: base_point, base_quat = multiply(gripper_pose, gripper_from_base) x, y, _ = base_point _, _, theta = euler_from_quat(base_quat) base_values = (x, y, theta) yield base_values ##################################### # Camera MAX_VISUAL_DISTANCE = 5.0 MAX_KINECT_DISTANCE = 2.5 HSR_CAMERA_MATRIX = get_camera_matrix( width=640, height=480, fx=772.55, fy=772.5) def get_hsr_view_section(z, camera_matrix=None): if camera_matrix is None: camera_matrix = HSR_CAMERA_MATRIX width, height = dimensions_from_camera_matrix(camera_matrix) pixels = [(0, 0), (width, height)] return [z*ray_from_pixel(camera_matrix, p) for p in pixels] def get_hsr_field_of_view(**kwargs): z = 1 view_lower, view_upper = get_hsr_view_section(z=z, **kwargs) horizontal = angle_between([view_lower[0], 0, z], [view_upper[0], 0, z]) vertical = angle_between([0, view_lower[1], z], [0, view_upper[1], z]) return horizontal, vertical def is_visible_point(camera_matrix, depth, point_world, camera_pose=unit_pose()): point_camera = tform_point(invert(camera_pose), point_world) if not (0 <= point_camera[2] < depth): return False pixel = pixel_from_point(camera_matrix, point_camera) return pixel is not None def is_visible_aabb(aabb, **kwargs): body_lower, body_upper = aabb z = body_lower[2] if z < 0: return False view_lower, view_upper = get_hsr_view_section(z, **kwargs) return not (np.any(body_lower[:2] < view_lower[:2]) or np.any(view_upper[:2] < body_upper[:2])) def support_from_aabb(aabb, near=True): lower, upper = aabb min_x, min_y, min_z = lower max_x, max_y, max_z = upper z = min_z if near else max_z return [(min_x, min_y, z), (min_x, max_y, z), (max_x, max_y, z), (max_x, min_y, z)] ##################################### def cone_vertices_from_base(base): return [np.zeros(3)] + base def cone_wires_from_support(support, cone_only=True): apex = np.zeros(3) lines = [] for vertex in support: lines.append((apex, vertex)) if cone_only: for i, v2 in enumerate(support): v1 = support[i-1] lines.append((v1, v2)) else: for v1, v2 in combinations(support, 2): lines.append((v1, v2)) center = np.average(support, axis=0) lines.append((apex, center)) return lines def cone_mesh_from_support(support): assert(len(support) == 4) vertices = cone_vertices_from_base(support) faces = [(1, 4, 3), (1, 3, 2)] for i in range(len(support)): index1 = 1+i index2 = 1+(i+1)%len(support) faces.append((0, index1, index2)) return vertices, faces def get_viewcone_base(depth=MAX_VISUAL_DISTANCE, camera_matrix=None): if camera_matrix is None: camera_matrix = HSR_CAMERA_MATRIX width, height = dimensions_from_camera_matrix(camera_matrix) vertices = [] for pixel in [(0, 0), (width, 0), (width, height), (0, height)]: ray = depth * ray_from_pixel(camera_matrix, pixel) vertices.append(ray[:3]) return vertices def get_viewcone(depth=MAX_VISUAL_DISTANCE, camera_matrix=None, **kwargs): mesh = cone_mesh_from_support(get_viewcone_base( depth=depth, camera_matrix=camera_matrix)) assert (mesh is not None) return create_mesh(mesh, **kwargs) def attach_viewcone(robot, head_name=HEAD_LINK_NAME, depth=MAX_VISUAL_DISTANCE, camera_matrix=None, color=(1, 0, 0), **kwargs): head_link = link_from_name(robot, head_name) lines = [] for v1, v2 in cone_wires_from_support(get_viewcone_base( depth=depth, camera_matrix=camera_matrix)): if is_optical(head_name): rotation = Pose() else: rotation = Pose(euler=Euler(roll=-np.pi/2, yaw=-np.pi/2)) # Apply in reverse order p1 = tform_point(rotation, v1) p2 = tform_point(rotation, v2) lines.append(add_line(p1, p2, color=color, parent=robot, parent_link=head_link, **kwargs)) return lines def draw_viewcone(pose, depth=MAX_VISUAL_DISTANCE, camera_matrix=None, color=(1, 0, 0), **kwargs): lines = [] for v1, v2 in cone_wires_from_support(get_viewcone_base( depth=depth, camera_matrix=camera_matrix)): p1 = tform_point(pose, v1) p2 = tform_point(pose, v2) lines.append(add_line(p1, p2, color=color, **kwargs)) return lines ##################################### def is_optical(link_name): return 'optical' in link_name def inverse_visibility(hsr, point, head_name=HEAD_LINK_NAME, head_joints=None, max_iterations=100, step_size=0.5, tolerance=np.pi*1e-2, verbose=False): head_link = link_from_name(hsr, head_name) camera_axis = np.array([0, 0, 1]) if is_optical(head_name) else np.array([1, 0, 0]) if head_joints is None: head_joints = joints_from_names(hsr, HSR_GROUPS['head']) head_conf = np.zeros(len(head_joints)) with LockRenderer(lock=True): with ConfSaver(hsr): for iteration in range(max_iterations): set_joint_positions(hsr, head_joints, head_conf) world_from_head = get_link_pose(hsr, head_link) point_head = tform_point(invert(world_from_head), point) error_angle = angle_between(camera_axis, point_head) if abs(error_angle) <= tolerance: break normal_head = np.cross(camera_axis, point_head) normal_world = tform_point((unit_point(), quat_from_pose(world_from_head)), normal_head) correction_quat = quat_from_axis_angle(normal_world, step_size*error_angle) correction_euler = euler_from_quat(correction_quat) _, angular = compute_jacobian(hsr, head_link) correction_conf = np.array([np.dot(angular[mj], correction_euler) for mj in movable_from_joints(hsr, head_joints)]) if verbose: print('Iteration: {} | Error: {:.3f} | Correction: {}'.format( iteration, error_angle, correction_conf)) head_conf += correction_conf if np.all(correction_conf == 0): return None else: return None if violates_limits(hsr, head_joints, head_conf): return None return head_conf def plan_scan_path(hsr, tilt=0): head_joints = joints_from_names(hsr, HSR_GROUPS['head']) start_conf = get_joint_positions(hsr, head_joints) lower_limit, upper_limit = get_joint_limits(hsr, head_joints[0]) first_conf = np.array([lower_limit, tilt]) second_conf = np.array([upper_limit, tilt]) if start_conf[0] > 0: first_conf, second_conf = second_conf, first_conf return [first_conf, second_conf] def plan_pause_scan_path(hsr, tilt=0): head_joints = joints_from_names(hsr, HSR_GROUPS['head']) assert(not violates_limit(hsr, head_joints[1], tilt)) theta, _ = get_hsr_field_of_view() lower_limit, upper_limit = get_joint_limits(hsr, head_joints[0]) # Add one because half visible on limits n = int(np.math.ceil((upper_limit - lower_limit) / theta) + 1) epsilon = 1e-3 return [np.array([pan, tilt]) for pan in np.linspace(lower_limit + epsilon, upper_limit - epsilon, n, endpoint=True)] ##################################### Detection = namedtuple('Detection', ['body', 'distance']) def get_view_aabb(body, view_pose, **kwargs): with PoseSaver(body): body_view = multiply(invert(view_pose), get_pose(body)) set_pose(body, body_view) return get_aabb(body, **kwargs) def get_view_oobb(body, view_pose, **kwargs): return OOBB(get_view_aabb(body, view_pose, **kwargs), view_pose) def get_detection_cone(hsr, body, camera_link=HEAD_LINK_NAME, depth=MAX_VISUAL_DISTANCE, **kwargs): head_link = link_from_name(hsr, camera_link) body_aabb = get_view_aabb(body, get_link_pose(hsr, head_link)) lower_z = body_aabb[0][2] if depth < lower_z: return None, lower_z if not is_visible_aabb(body_aabb, **kwargs): return None, lower_z return cone_mesh_from_support(support_from_aabb(body_aabb)), lower_z def get_detections(hsr, p_false_neg=0, camera_link=HEAD_LINK_NAME, exclude_links=set(), color=None, **kwargs): camera_pose = get_link_pose(hsr, link_from_name(hsr, camera_link)) detections = [] for body in get_bodies(): if (hsr == body) or (np.random.random() < p_false_neg): continue mesh, z = get_detection_cone(hsr, body, camera_link=camera_link, **kwargs) if mesh is None: continue cone = create_mesh(mesh, color=color) set_pose(cone, camera_pose) if not any(pairwise_collision(cone, obst) for obst in set(get_bodies()) - {hsr, body, cone}) \ and not any(link_pairs_collision(hsr, [link], cone) for link in set(get_all_links(hsr)) - exclude_links): detections.append(Detection(body, z)) remove_body(cone) return detections def get_visual_detections(hsr, **kwargs): return [body for body, _ in get_detections(hsr, depth=MAX_VISUAL_DISTANCE, **kwargs)] def get_kinect_registrations(hsr, **kwargs): return [body for body, _ in get_detections(hsr, depth=MAX_KINECT_DISTANCE, **kwargs)] ##################################### def visible_base_generator(robot, target_point, base_range=(1., 1.), theta_range=(0., 0.)): while True: base_from_target = unit_from_theta(np.random.uniform(0., 2 * np.pi)) look_distance = np.random.uniform(*base_range) base_xy = target_point[:2] - look_distance * base_from_target base_theta = np.math.atan2(base_from_target[1], base_from_target[0]) + np.random.uniform(*theta_range) base_q = np.append(base_xy, wrap_angle(base_theta)) yield base_q def get_base_extend_fn(robot): raise NotImplementedError() ##################################### def close_until_collision(robot, gripper_joints, bodies=[], open_conf=None, closed_conf=None, num_steps=25, **kwargs): if not gripper_joints: return None if open_conf is None: open_conf = [get_max_limit(robot, joint) for joint in gripper_joints] if closed_conf is None: closed_conf = [get_min_limit(robot, joint) for joint in gripper_joints] resolutions = np.abs(np.array(open_conf) - np.array(closed_conf)) / num_steps extend_fn = get_extend_fn(robot, gripper_joints, resolutions=resolutions) close_path = [open_conf] + list(extend_fn(open_conf, closed_conf)) collision_links = frozenset(get_moving_links(robot, gripper_joints)) for i, conf in enumerate(close_path): set_joint_positions(robot, gripper_joints, conf) if any(pairwise_collision((robot, collision_links), body, **kwargs) for body in bodies): if i == 0: return None return close_path[i-1][0] return close_path[-1][0] def compute_grasp_width(robot, arm, body, grasp_pose, **kwargs): tool_link = get_gripper_link(robot, arm) tool_pose = get_link_pose(robot, tool_link) body_pose = multiply(tool_pose, grasp_pose) set_pose(body, body_pose) gripper_joints = get_gripper_joints(robot, arm) return close_until_collision(robot, gripper_joints, bodies=[body], **kwargs) def create_gripper(robot, arm, visual=True): # link_name = HSR_GRIPPER_ROOTS[arm] # links = get_link_subtree(robot, link_from_name(robot, link_name)) # gripper = clone_body(robot, links=links, visual=False, collision=True) gripper = get_gripper_link(robot, arm) if not visual: set_all_color(robot, TRANSPARENT) return gripper
26,893
Python
38.376281
177
0.613617
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/pr2_primitives.py
from __future__ import print_function import copy import pybullet as p import random import time from itertools import islice, count import numpy as np from .ikfast.pr2.ik import is_ik_compiled, pr2_inverse_kinematics from .ikfast.utils import USE_CURRENT, USE_ALL from .pr2_problems import get_fixed_bodies from .pr2_utils import TOP_HOLDING_LEFT_ARM, SIDE_HOLDING_LEFT_ARM, GET_GRASPS, get_gripper_joints, \ get_carry_conf, get_top_grasps, get_side_grasps, open_arm, arm_conf, get_gripper_link, get_arm_joints, \ learned_pose_generator, PR2_TOOL_FRAMES, get_x_presses, PR2_GROUPS, joints_from_names, \ is_drake_pr2, get_group_joints, get_group_conf, compute_grasp_width, PR2_GRIPPER_ROOTS from .utils import invert, multiply, get_name, set_pose, get_link_pose, is_placement, \ pairwise_collision, set_joint_positions, get_joint_positions, sample_placement, get_pose, waypoints_from_path, \ unit_quat, plan_base_motion, plan_joint_motion, base_values_from_pose, pose_from_base_values, \ uniform_pose_generator, sub_inverse_kinematics, add_fixed_constraint, remove_debug, remove_fixed_constraint, \ disable_real_time, enable_gravity, joint_controller_hold, get_distance, \ get_min_limit, user_input, step_simulation, get_body_name, get_bodies, BASE_LINK, \ add_segments, get_max_limit, link_from_name, BodySaver, get_aabb, Attachment, interpolate_poses, \ plan_direct_joint_motion, has_gui, create_attachment, wait_for_duration, get_extend_fn, set_renderer, \ get_custom_limits, all_between, get_unit_vector, wait_if_gui, \ set_base_values, euler_from_quat, INF, elapsed_time, get_moving_links, flatten_links, get_relative_pose BASE_EXTENT = 3.5 # 2.5 BASE_LIMITS = (-BASE_EXTENT*np.ones(2), BASE_EXTENT*np.ones(2)) GRASP_LENGTH = 0.03 APPROACH_DISTANCE = 0.1 + GRASP_LENGTH SELF_COLLISIONS = False BASE_CONSTANT = 1 BASE_VELOCITY = 0.25 def distance_fn(q1, q2): distance = get_distance(q1.values[:2], q2.values[:2]) return BASE_CONSTANT + distance / BASE_VELOCITY def move_cost_fn(t): distance = t.distance(distance_fn=lambda q1, q2: get_distance(q1[:2], q2[:2])) return BASE_CONSTANT + distance / BASE_VELOCITY ####################################################### def get_cfree_pose_pose_test(collisions=True, **kwargs): def test(b1, p1, b2, p2): if not collisions or (b1 == b2): return True p1.assign() p2.assign() return not pairwise_collision(b1, b2, **kwargs) #, max_distance=0.001) return test def get_cfree_obj_approach_pose_test(collisions=True): def test(b1, p1, g1, b2, p2): if not collisions or (b1 == b2): return True p2.assign() grasp_pose = multiply(p1.value, invert(g1.value)) approach_pose = multiply(p1.value, invert(g1.approach), g1.value) for obj_pose in interpolate_poses(grasp_pose, approach_pose): set_pose(b1, obj_pose) if pairwise_collision(b1, b2): return False return True return test def get_cfree_approach_pose_test(problem, collisions=True): # TODO: apply this before inverse kinematics as well arm = 'left' gripper = problem.get_gripper() def test(b1, p1, g1, b2, p2): if not collisions or (b1 == b2): return True p2.assign() for _ in iterate_approach_path(problem.robot, arm, gripper, p1, g1, body=b1): if pairwise_collision(b1, b2) or pairwise_collision(gripper, b2): return False return True return test def get_cfree_traj_pose_test(robot, collisions=True): def test(c, b2, p2): # TODO: infer robot from c if not collisions: return True state = c.assign() if b2 in state.attachments: return True p2.assign() for _ in c.apply(state): state.assign() for b1 in state.attachments: if pairwise_collision(b1, b2): #wait_for_user() return False if pairwise_collision(robot, b2): return False # TODO: just check collisions with moving links return True return test def get_cfree_traj_grasp_pose_test(problem, collisions=True): def test(c, a, b1, g, b2, p2): raise NotImplementedError() if not collisions or (b1 == b2): return True state = c.assign() if (b1 in state.attachments) or (b2 in state.attachments): return True p2.assign() grasp_attachment = g.get_attachment(problem.robot, a) for _ in c.apply(state): state.assign() grasp_attachment.assign() if pairwise_collision(b1, b2): return False if pairwise_collision(problem.robot, b2): return False return True return ################################################## def get_base_limits(robot): if is_drake_pr2(robot): joints = get_group_joints(robot, 'base')[:2] lower = [get_min_limit(robot, j) for j in joints] upper = [get_max_limit(robot, j) for j in joints] return lower, upper return BASE_LIMITS ################################################## class Pose(object): num = count() #def __init__(self, position, orientation): # self.position = position # self.orientation = orientation def __init__(self, body, value=None, support=None, init=False): self.body = body if value is None: value = get_pose(self.body) self.value = tuple(value) self.support = support self.init = init self.index = next(self.num) @property def bodies(self): return flatten_links(self.body) def assign(self): set_pose(self.body, self.value) def iterate(self): yield self def to_base_conf(self): values = base_values_from_pose(self.value) return Conf(self.body, range(len(values)), values) def __repr__(self): index = self.index #index = id(self) % 1000 return 'p{}'.format(index) class Grasp(object): def __init__(self, grasp_type, body, value, approach, carry): self.grasp_type = grasp_type self.body = body self.value = tuple(value) # gripper_from_object self.approach = tuple(approach) self.carry = tuple(carry) def get_attachment(self, robot, arm): tool_link = link_from_name(robot, PR2_TOOL_FRAMES[arm]) return Attachment(robot, tool_link, self.value, self.body) def __repr__(self): return 'g{}'.format(id(self) % 1000) class Conf(object): def __init__(self, body, joints, values=None, init=False): self.body = body self.joints = joints if values is None: values = get_joint_positions(self.body, self.joints) self.values = tuple(values) self.init = init @property def bodies(self): # TODO: misnomer return flatten_links(self.body, get_moving_links(self.body, self.joints)) def assign(self): set_joint_positions(self.body, self.joints, self.values) def iterate(self): yield self def __repr__(self): return 'q{}'.format(id(self) % 1000) ##################################### class Command(object): def control(self, dt=0): raise NotImplementedError() def apply(self, state, **kwargs): raise NotImplementedError() def iterate(self): raise NotImplementedError() class Commands(object): def __init__(self, state, savers=[], commands=[]): self.state = state self.savers = tuple(savers) self.commands = tuple(commands) def assign(self): for saver in self.savers: saver.restore() return copy.copy(self.state) def apply(self, state, **kwargs): for command in self.commands: for result in command.apply(state, **kwargs): yield result def __repr__(self): return 'c{}'.format(id(self) % 1000) ##################################### class Trajectory(Command): _draw = False def __init__(self, path): self.path = tuple(path) # TODO: constructor that takes in this info def apply(self, state, sample=1): handles = add_segments(self.to_points()) if self._draw and has_gui() else [] for conf in self.path[::sample]: conf.assign() yield end_conf = self.path[-1] if isinstance(end_conf, Pose): state.poses[end_conf.body] = end_conf for handle in handles: remove_debug(handle) def control(self, dt=0, **kwargs): # TODO: just waypoints for conf in self.path: if isinstance(conf, Pose): conf = conf.to_base_conf() for _ in joint_controller_hold(conf.body, conf.joints, conf.values): step_simulation() time.sleep(dt) def to_points(self, link=BASE_LINK): # TODO: this is computationally expensive points = [] for conf in self.path: with BodySaver(conf.body): conf.assign() #point = np.array(point_from_pose(get_link_pose(conf.body, link))) point = np.array(get_group_conf(conf.body, 'base')) point[2] = 0 point += 1e-2*np.array([0, 0, 1]) if not (points and np.allclose(points[-1], point, atol=1e-3, rtol=0)): points.append(point) points = get_target_path(self) return waypoints_from_path(points) def distance(self, distance_fn=get_distance): total = 0. for q1, q2 in zip(self.path, self.path[1:]): total += distance_fn(q1.values, q2.values) return total def iterate(self): for conf in self.path: yield conf def reverse(self): return Trajectory(reversed(self.path)) #def __repr__(self): # return 't{}'.format(id(self) % 1000) def __repr__(self): d = 0 if self.path: conf = self.path[0] d = 3 if isinstance(conf, Pose) else len(conf.joints) return 't({},{})'.format(d, len(self.path)) def create_trajectory(robot, joints, path): return Trajectory(Conf(robot, joints, q) for q in path) ################################################## class GripperCommand(Command): def __init__(self, robot, arm, position, teleport=False): self.robot = robot self.arm = arm self.position = position self.teleport = teleport def apply(self, state, **kwargs): joints = get_gripper_joints(self.robot, self.arm) start_conf = get_joint_positions(self.robot, joints) end_conf = [self.position] * len(joints) if self.teleport: path = [start_conf, end_conf] else: extend_fn = get_extend_fn(self.robot, joints) path = [start_conf] + list(extend_fn(start_conf, end_conf)) for positions in path: set_joint_positions(self.robot, joints, positions) yield positions def control(self, **kwargs): joints = get_gripper_joints(self.robot, self.arm) positions = [self.position]*len(joints) for _ in joint_controller_hold(self.robot, joints, positions): yield def __repr__(self): return '{}({},{},{})'.format(self.__class__.__name__, get_body_name(self.robot), self.arm, self.position) class Attach(Command): vacuum = True def __init__(self, robot, arm, grasp, body): self.robot = robot self.arm = arm self.grasp = grasp self.body = body self.link = link_from_name(self.robot, PR2_TOOL_FRAMES.get(self.arm, self.arm)) #self.attachment = None def assign(self): gripper_pose = get_link_pose(self.robot, self.link) body_pose = multiply(gripper_pose, self.grasp.value) set_pose(self.body, body_pose) def apply(self, state, **kwargs): state.attachments[self.body] = create_attachment(self.robot, self.link, self.body) state.grasps[self.body] = self.grasp del state.poses[self.body] yield def control(self, dt=0, **kwargs): if self.vacuum: add_fixed_constraint(self.body, self.robot, self.link) #add_fixed_constraint(self.body, self.robot, self.link, max_force=1) # Less force makes it easier to pick else: # TODO: the gripper doesn't quite work yet gripper_name = '{}_gripper'.format(self.arm) joints = joints_from_names(self.robot, PR2_GROUPS[gripper_name]) values = [get_min_limit(self.robot, joint) for joint in joints] # Closed for _ in joint_controller_hold(self.robot, joints, values): step_simulation() time.sleep(dt) def __repr__(self): return '{}({},{},{})'.format(self.__class__.__name__, get_body_name(self.robot), self.arm, get_name(self.body)) class Detach(Command): def __init__(self, robot, arm, body): self.robot = robot self.arm = arm self.body = body self.link = link_from_name(self.robot, PR2_TOOL_FRAMES.get(self.arm, self.arm)) # TODO: pose argument to maintain same object def apply(self, state, **kwargs): del state.attachments[self.body] state.poses[self.body] = Pose(self.body, get_pose(self.body)) del state.grasps[self.body] yield def control(self, **kwargs): remove_fixed_constraint(self.body, self.robot, self.link) def __repr__(self): return '{}({},{},{})'.format(self.__class__.__name__, get_body_name(self.robot), self.arm, get_name(self.body)) ################################################## class Clean(Command): def __init__(self, body): self.body = body def apply(self, state, **kwargs): state.cleaned.add(self.body) self.control() yield def control(self, **kwargs): p.addUserDebugText('Cleaned', textPosition=(0, 0, .25), textColorRGB=(0,0,1), #textSize=1, lifeTime=0, parentObjectUniqueId=self.body) #p.setDebugObjectColor(self.body, 0, objectDebugColorRGB=(0,0,1)) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) class Cook(Command): # TODO: global state here? def __init__(self, body): self.body = body def apply(self, state, **kwargs): state.cleaned.remove(self.body) state.cooked.add(self.body) self.control() yield def control(self, **kwargs): # changeVisualShape # setDebugObjectColor #p.removeUserDebugItem # TODO: remove cleaned p.addUserDebugText('Cooked', textPosition=(0, 0, .5), textColorRGB=(1,0,0), #textSize=1, lifeTime=0, parentObjectUniqueId=self.body) #p.setDebugObjectColor(self.body, 0, objectDebugColorRGB=(1,0,0)) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) ################################################## def get_grasp_gen(problem, collisions=False, randomize=True): for grasp_type in problem.grasp_types: if grasp_type not in GET_GRASPS: raise ValueError('Unexpected grasp type:', grasp_type) def fn(body): # TODO: max_grasps # TODO: return grasps one by one grasps = [] arm = 'left' #carry_conf = get_carry_conf(arm, 'top') if 'top' in problem.grasp_types: approach_vector = APPROACH_DISTANCE*get_unit_vector([1, 0, 0]) grasps.extend(Grasp('top', body, g, multiply((approach_vector, unit_quat()), g), TOP_HOLDING_LEFT_ARM) for g in get_top_grasps(body, grasp_length=GRASP_LENGTH)) if 'side' in problem.grasp_types: approach_vector = APPROACH_DISTANCE*get_unit_vector([2, 0, -1]) grasps.extend(Grasp('side', body, g, multiply((approach_vector, unit_quat()), g), SIDE_HOLDING_LEFT_ARM) for g in get_side_grasps(body, grasp_length=GRASP_LENGTH)) filtered_grasps = [] for grasp in grasps: grasp_width = compute_grasp_width(problem.robot, arm, body, grasp.value) if collisions else 0.0 if grasp_width is not None: grasp.grasp_width = grasp_width filtered_grasps.append(grasp) if randomize: random.shuffle(filtered_grasps) return [(g,) for g in filtered_grasps] #for g in filtered_grasps: # yield (g,) return fn ################################################## def accelerate_gen_fn(gen_fn, max_attempts=1): def new_gen_fn(*inputs): generator = gen_fn(*inputs) while True: for i in range(max_attempts): try: output = next(generator) except StopIteration: return if output is not None: print(gen_fn.__name__, i) yield output break return new_gen_fn def get_stable_gen(problem, collisions=True, **kwargs): obstacles = problem.fixed if collisions else [] def gen(body, surface): # TODO: surface poses are being sampled in pr2_belief if surface is None: surfaces = problem.surfaces else: surfaces = [surface] while True: surface = random.choice(surfaces) # TODO: weight by area body_pose = sample_placement(body, surface, **kwargs) if body_pose is None: break p = Pose(body, body_pose, surface) p.assign() if not any(pairwise_collision(body, obst) for obst in obstacles if obst not in {body, surface}): yield (p,) # TODO: apply the acceleration technique here return gen ################################################## def get_tool_from_root(robot, arm): root_link = link_from_name(robot, PR2_GRIPPER_ROOTS[arm]) tool_link = link_from_name(robot, PR2_TOOL_FRAMES[arm]) return get_relative_pose(robot, root_link, tool_link) def iterate_approach_path(robot, arm, gripper, pose, grasp, body=None): tool_from_root = get_tool_from_root(robot, arm) grasp_pose = multiply(pose.value, invert(grasp.value)) approach_pose = multiply(pose.value, invert(grasp.approach)) for tool_pose in interpolate_poses(grasp_pose, approach_pose): set_pose(gripper, multiply(tool_pose, tool_from_root)) if body is not None: set_pose(body, multiply(tool_pose, grasp.value)) yield def get_ir_sampler(problem, custom_limits={}, max_attempts=25, collisions=True, learned=True): robot = problem.robot obstacles = problem.fixed if collisions else [] gripper = problem.get_gripper() def gen_fn(arm, obj, pose, grasp): pose.assign() approach_obstacles = {obst for obst in obstacles if not is_placement(obj, obst)} for _ in iterate_approach_path(robot, arm, gripper, pose, grasp, body=obj): if any(pairwise_collision(gripper, b) or pairwise_collision(obj, b) for b in approach_obstacles): return gripper_pose = multiply(pose.value, invert(grasp.value)) # w_f_g = w_f_o * (g_f_o)^-1 default_conf = arm_conf(arm, grasp.carry) arm_joints = get_arm_joints(robot, arm) base_joints = get_group_joints(robot, 'base') if learned: base_generator = learned_pose_generator(robot, gripper_pose, arm=arm, grasp_type=grasp.grasp_type) else: base_generator = uniform_pose_generator(robot, gripper_pose) lower_limits, upper_limits = get_custom_limits(robot, base_joints, custom_limits) while True: count = 0 for base_conf in islice(base_generator, max_attempts): count += 1 if not all_between(lower_limits, base_conf, upper_limits): continue bq = Conf(robot, base_joints, base_conf) pose.assign() bq.assign() set_joint_positions(robot, arm_joints, default_conf) if any(pairwise_collision(robot, b) for b in obstacles + [obj]): continue #print('IR attempts:', count) yield (bq,) break else: yield None return gen_fn ################################################## def get_ik_fn(problem, custom_limits={}, collisions=True, teleport=False): robot = problem.robot obstacles = problem.fixed if collisions else [] if is_ik_compiled(): print('Using ikfast for inverse kinematics') else: print('Using pybullet for inverse kinematics') def fn(arm, obj, pose, grasp, base_conf): approach_obstacles = {obst for obst in obstacles if not is_placement(obj, obst)} gripper_pose = multiply(pose.value, invert(grasp.value)) # w_f_g = w_f_o * (g_f_o)^-1 #approach_pose = multiply(grasp.approach, gripper_pose) approach_pose = multiply(pose.value, invert(grasp.approach)) arm_link = get_gripper_link(robot, arm) arm_joints = get_arm_joints(robot, arm) default_conf = arm_conf(arm, grasp.carry) #sample_fn = get_sample_fn(robot, arm_joints) pose.assign() base_conf.assign() open_arm(robot, arm) set_joint_positions(robot, arm_joints, default_conf) # default_conf | sample_fn() grasp_conf = pr2_inverse_kinematics(robot, arm, gripper_pose, custom_limits=custom_limits) #, upper_limits=USE_CURRENT) #nearby_conf=USE_CURRENT) # upper_limits=USE_CURRENT, if (grasp_conf is None) or any(pairwise_collision(robot, b) for b in obstacles): # [obj] #print('Grasp IK failure', grasp_conf) #if grasp_conf is not None: # print(grasp_conf) # #wait_if_gui() return None #approach_conf = pr2_inverse_kinematics(robot, arm, approach_pose, custom_limits=custom_limits, # upper_limits=USE_CURRENT, nearby_conf=USE_CURRENT) approach_conf = sub_inverse_kinematics(robot, arm_joints[0], arm_link, approach_pose, custom_limits=custom_limits) if (approach_conf is None) or any(pairwise_collision(robot, b) for b in obstacles + [obj]): #print('Approach IK failure', approach_conf) #wait_if_gui() return None approach_conf = get_joint_positions(robot, arm_joints) attachment = grasp.get_attachment(problem.robot, arm) attachments = {attachment.child: attachment} if teleport: path = [default_conf, approach_conf, grasp_conf] else: resolutions = 0.05**np.ones(len(arm_joints)) grasp_path = plan_direct_joint_motion(robot, arm_joints, grasp_conf, attachments=attachments.values(), obstacles=approach_obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions/2.) if grasp_path is None: print('Grasp path failure') return None set_joint_positions(robot, arm_joints, default_conf) approach_path = plan_joint_motion(robot, arm_joints, approach_conf, attachments=attachments.values(), obstacles=obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions, restarts=2, iterations=25, smooth=25) if approach_path is None: print('Approach path failure') return None path = approach_path + grasp_path mt = create_trajectory(robot, arm_joints, path) cmd = Commands(State(attachments=attachments), savers=[BodySaver(robot)], commands=[mt]) return (cmd,) return fn ################################################## def get_ik_ir_gen(problem, max_attempts=25, learned=True, teleport=False, **kwargs): # TODO: compose using general fn ir_sampler = get_ir_sampler(problem, learned=learned, max_attempts=1, **kwargs) ik_fn = get_ik_fn(problem, teleport=teleport, **kwargs) def gen(*inputs): b, a, p, g = inputs ir_generator = ir_sampler(*inputs) attempts = 0 while True: if max_attempts <= attempts: if not p.init: return attempts = 0 yield None attempts += 1 try: ir_outputs = next(ir_generator) except StopIteration: return if ir_outputs is None: continue ik_outputs = ik_fn(*(inputs + ir_outputs)) if ik_outputs is None: continue print('IK attempts:', attempts) yield ir_outputs + ik_outputs return #if not p.init: # return return gen ################################################## def get_motion_gen(problem, custom_limits={}, collisions=True, teleport=False): # TODO: include fluents robot = problem.robot saver = BodySaver(robot) obstacles = problem.fixed if collisions else [] def fn(bq1, bq2, fluents=[]): saver.restore() bq1.assign() if teleport: path = [bq1, bq2] elif is_drake_pr2(robot): raw_path = plan_joint_motion(robot, bq2.joints, bq2.values, attachments=[], obstacles=obstacles, custom_limits=custom_limits, self_collisions=SELF_COLLISIONS, restarts=4, iterations=50, smooth=50) if raw_path is None: print('Failed motion plan!') #set_renderer(True) #for bq in [bq1, bq2]: # bq.assign() # wait_if_gui() return None path = [Conf(robot, bq2.joints, q) for q in raw_path] else: goal_conf = base_values_from_pose(bq2.value) raw_path = plan_base_motion(robot, goal_conf, BASE_LIMITS, obstacles=obstacles) if raw_path is None: print('Failed motion plan!') return None path = [Pose(robot, pose_from_base_values(q, bq1.value)) for q in raw_path] bt = Trajectory(path) cmd = Commands(State(), savers=[BodySaver(robot)], commands=[bt]) return (cmd,) return fn ################################################## def get_press_gen(problem, max_attempts=25, learned=True, teleport=False): robot = problem.robot fixed = get_fixed_bodies(problem) def gen(arm, button): fixed_wo_button = list(filter(lambda b: b != button, fixed)) pose = get_pose(button) grasp_type = 'side' link = get_gripper_link(robot, arm) default_conf = get_carry_conf(arm, grasp_type) joints = get_arm_joints(robot, arm) presses = get_x_presses(button) approach = ((APPROACH_DISTANCE, 0, 0), unit_quat()) while True: for _ in range(max_attempts): press_pose = random.choice(presses) gripper_pose = multiply(pose, invert(press_pose)) # w_f_g = w_f_o * (g_f_o)^-1 #approach_pose = gripper_pose # w_f_g * g_f_o * o_f_a = w_f_a approach_pose = multiply(gripper_pose, invert(multiply(press_pose, approach))) if learned: base_generator = learned_pose_generator(robot, gripper_pose, arm=arm, grasp_type=grasp_type) else: base_generator = uniform_pose_generator(robot, gripper_pose) set_joint_positions(robot, joints, default_conf) set_pose(robot, next(base_generator)) raise NotImplementedError('Need to change this') if any(pairwise_collision(robot, b) for b in fixed): continue approach_movable_conf = sub_inverse_kinematics(robot, joints[0], link, approach_pose) #approach_movable_conf = inverse_kinematics(robot, link, approach_pose) if (approach_movable_conf is None) or any(pairwise_collision(robot, b) for b in fixed): continue approach_conf = get_joint_positions(robot, joints) gripper_movable_conf = sub_inverse_kinematics(robot, joints[0], link, gripper_pose) #gripper_movable_conf = inverse_kinematics(robot, link, gripper_pose) if (gripper_movable_conf is None) or any(pairwise_collision(robot, b) for b in fixed_wo_button): continue grasp_conf = get_joint_positions(robot, joints) bp = Pose(robot, get_pose(robot)) # TODO: don't use this if teleport: path = [default_conf, approach_conf, grasp_conf] else: control_path = plan_direct_joint_motion(robot, joints, approach_conf, obstacles=fixed_wo_button, self_collisions=SELF_COLLISIONS) if control_path is None: continue set_joint_positions(robot, joints, approach_conf) retreat_path = plan_joint_motion(robot, joints, default_conf, obstacles=fixed, self_collisions=SELF_COLLISIONS) if retreat_path is None: continue path = retreat_path[::-1] + control_path[::-1] mt = Trajectory(Conf(robot, joints, q) for q in path) yield (bp, mt) break else: yield None return gen ##################################### def control_commands(commands, **kwargs): wait_if_gui('Control?') disable_real_time() enable_gravity() for i, command in enumerate(commands): print(i, command) command.control(*kwargs) class State(object): def __init__(self, attachments={}, cleaned=set(), cooked=set()): self.poses = {body: Pose(body, get_pose(body)) for body in get_bodies() if body not in attachments} self.grasps = {} self.attachments = attachments self.cleaned = cleaned self.cooked = cooked def assign(self): for attachment in self.attachments.values(): #attach.attachment.assign() attachment.assign() def apply_commands(state, commands, time_step=None, pause=False, **kwargs): #wait_if_gui('Apply?') for i, command in enumerate(commands): print(i, command) for j, _ in enumerate(command.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) wait_if_gui('Command {}, Step {}) Next?'.format(i, j)) else: wait_for_duration(time_step) if pause: wait_if_gui() ##################################### def get_target_point(conf): # TODO: use full body aabb robot = conf.body link = link_from_name(robot, 'torso_lift_link') #link = BASE_LINK # TODO: center of mass instead? # TODO: look such that cone bottom touches at bottom # TODO: the target isn't the center which causes it to drift with BodySaver(conf.body): conf.assign() lower, upper = get_aabb(robot, link) center = np.average([lower, upper], axis=0) point = np.array(get_group_conf(conf.body, 'base')) #point[2] = upper[2] point[2] = center[2] #center, _ = get_center_extent(conf.body) return point def get_target_path(trajectory): # TODO: only do bounding boxes for moving links on the trajectory return [get_target_point(conf) for conf in trajectory.path]
32,585
Python
39.937186
127
0.56793
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/hsrb_problems.py
import os import random import numpy as np from itertools import product from .hsrb_utils import set_arm_conf, set_group_conf, get_carry_conf, get_other_arm, \ create_gripper, arm_conf, open_arm, close_arm, HSRB_URDF from .utils import ( # Setter set_base_values, set_point, set_pose, \ # Getter get_pose, get_bodies, get_box_geometry, get_cylinder_geometry, \ # Utility create_body, create_box, create_virtual_box, create_shape_array, create_virtual_cylinder, create_marker, \ z_rotation, add_data_path, remove_body, load_model, load_pybullet, load_virtual_model, \ LockRenderer, HideOutput, \ # Geometry Point, Pose, \ # URDF FLOOR_URDF, TABLE_URDF, \ # Color LIGHT_GREY, TAN, GREY) class Problem(object): def __init__(self, robot, arms=tuple(), movable=tuple(), bodies=tuple(), fixed=tuple(), holes=tuple(), grasp_types=tuple(), surfaces=tuple(), sinks=tuple(), stoves=tuple(), buttons=tuple(), init_placeable=tuple(), init_insertable=tuple(), goal_conf=None, goal_holding=tuple(), goal_on=tuple(), goal_inserted=tuple(), goal_cleaned=tuple(), goal_cooked=tuple(), costs=False, body_names={}, body_types=[], base_limits=None): self.robot = robot self.arms = arms self.movable = movable self.grasp_types = grasp_types self.surfaces = surfaces self.sinks = sinks self.stoves = stoves self.buttons = buttons self.init_placeable = init_placeable self.init_insertable = init_insertable self.goal_conf = goal_conf self.goal_holding = goal_holding self.goal_on = goal_on self.goal_inserted = goal_inserted self.goal_cleaned = goal_cleaned self.goal_cooked = goal_cooked self.costs = costs self.bodies = bodies self.body_names = body_names self.body_types = body_types self.base_limits = base_limits self.holes = holes self.fixed = fixed # list(filter(lambda b: b not in all_movable, get_bodies())) self.gripper = None def get_gripper(self, arm='arm', visual=True): if self.gripper is None: self.gripper = create_gripper(self.robot, arm=arm, visual=visual) return self.gripper def remove_gripper(self): if self.gripper is not None: remove_body(self.gripper) self.gripper = None def __repr__(self): return repr(self.__dict__) ####################################################### def get_fixed_bodies(problem): return problem.fixed def create_hsr(fixed_base=True, torso=0.0): directory = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'models/hsrb_description') add_data_path(directory) hsr_path = HSRB_URDF hsr_init_pose = [(0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0)] with LockRenderer(): with HideOutput(): hsr = load_model(hsr_path, pose=hsr_init_pose, fixed_base=fixed_base) set_group_conf(hsr, 'torso', [torso]) return hsr def create_floor(**kwargs): directory = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'models') add_data_path(directory) return load_pybullet(FLOOR_URDF, **kwargs) def create_table(width=0.6, length=1.2, height=0.73, thickness=0.03, radius=0.015, top_color=LIGHT_GREY, leg_color=TAN, cylinder=True, **kwargs): surface = get_box_geometry(width, length, thickness) surface_pose = Pose(Point(z=height - thickness/2.)) leg_height = height-thickness if cylinder: leg_geometry = get_cylinder_geometry(radius, leg_height) else: leg_geometry = get_box_geometry(width=2*radius, length=2*radius, height=leg_height) legs = [leg_geometry for _ in range(4)] leg_center = np.array([width, length])/2. - radius*np.ones(2) leg_xys = [np.multiply(leg_center, np.array(signs)) for signs in product([-1, +1], repeat=len(leg_center))] leg_poses = [Pose(point=[x, y, leg_height/2.]) for x, y in leg_xys] geoms = [surface] + legs poses = [surface_pose] + leg_poses colors = [top_color] + len(legs)*[leg_color] collision_id, visual_id = create_shape_array(geoms, poses, colors) body = create_body(collision_id, visual_id, **kwargs) return body def create_door(): return load_pybullet("data/door.urdf") ####################################################### TABLE_MAX_Z = 0.6265 def holding_problem(arm='arm', grasp_type='side'): hsr = create_hsr() initial_conf = get_carry_conf(arm, grasp_type) set_base_values(hsr, (0, 0, 0)) set_arm_conf(hsr, arm, initial_conf) open_arm(hsr, arm) plane = create_floor(fixed_base=True) box = create_box(.04, .04, .04) set_point(box, (1.3, 0.0, 0.22)) table = create_box(0.65, 1.2, 0.20, color=(1, 1, 1, 1)) set_point(table, (1.5, 0.0, 0.1)) block_names = {box: 'block'} return Problem(robot=hsr, movable=[box], arms=[arm], body_names=block_names, grasp_types=[grasp_type], surfaces=[table], goal_holding=[(arm, box)]) def stacking_problem(arm='arm', grasp_type='side'): hsr = create_hsr() initial_conf = get_carry_conf(arm, grasp_type) set_base_values(hsr, (0, 0, 0)) set_arm_conf(hsr, arm, initial_conf) open_arm(hsr, arm) plane = create_floor(fixed_base=True) block1 = create_box(.04, .04, .04, color=(0.0, 1.0, 0.0, 1.0)) set_point(block1, (1.5, 0.45, 0.275)) table1 = create_box(0.5, 0.5, 0.25, color=(.25, .25, .75, 1)) set_point(table1, (1.5, 0.5, 0.125)) table2 = create_box(0.5, 0.5, 0.25, color=(.75, .25, .25, 1)) set_point(table2, (1.5, -0.5, 0.125)) block_names = {block1: 'block', table1: 'table1', table2: 'table2'} return Problem(robot=hsr, movable=[block1], arms=[arm], body_names=block_names, grasp_types=[grasp_type], surfaces=[table1, table2], goal_on=[(block1, table2)]) ####################################################### def create_kitchen(w=.5, h=.2): plane = create_floor(fixed_base=True) table = create_box(w, w, h, color=(.75, .75, .75, 1)) set_point(table, (2, 0, h/2)) mass = 1 cabbage = create_box(.07, .07, .1, mass=mass, color=(0, 1, 0, 1)) set_point(cabbage, (1.80, 0, h + .1/2)) sink = create_box(w, w, h, color=(.25, .25, .75, 1)) set_point(sink, (0, 2, h/2)) stove = create_box(w, w, h, color=(.75, .25, .25, 1)) set_point(stove, (0, -2, h/2)) return table, cabbage, sink, stove ####################################################### def cleaning_problem(arm='arm', grasp_type='side'): initial_conf = get_carry_conf(arm, grasp_type) hsr = create_hsr() set_arm_conf(hsr, arm, initial_conf) table, cabbage, sink, stove = create_kitchen() return Problem(robot=hsr, movable=[cabbage], arms=[arm], grasp_types=[grasp_type], surfaces=[table, sink, stove], sinks=[sink], stoves=[stove], goal_cleaned=[cabbage]) def cooking_problem(arm='arm', grasp_type='side'): initial_conf = get_carry_conf(arm, grasp_type) hsr = create_hsr() set_arm_conf(hsr, arm, initial_conf) table, cabbage, sink, stove = create_kitchen() return Problem(robot=hsr, movable=[cabbage], arms=[arm], grasp_types=[grasp_type], surfaces=[table, sink, stove], sinks=[sink], stoves=[stove], goal_cooked=[cabbage]) def cleaning_button_problem(arm='arm', grasp_type='side'): initial_conf = get_carry_conf(arm, grasp_type) hsr = create_hsr() set_arm_conf(hsr, arm, initial_conf) table, cabbage, sink, stove = create_kitchen() d = 0.1 sink_button = create_box(d, d, d, color=(0, 0, 0, 1)) set_pose(sink_button, ((0, 2-(.5+d)/2, .7-d/2), z_rotation(np.pi/2))) stove_button = create_box(d, d, d, color=(0, 0, 0, 1)) set_pose(stove_button, ((0, -2+(.5+d)/2, .7-d/2), z_rotation(-np.pi/2))) return Problem(robot=hsr, movable=[cabbage], arms=[arm], grasp_types=[grasp_type], surfaces=[table, sink, stove], sinks=[sink], stoves=[stove], buttons=[(sink_button, sink), (stove_button, stove)], goal_conf=get_pose(hsr), goal_holding=[(arm, cabbage)], goal_cleaned=[cabbage]) def cooking_button_problem(arm='arm', grasp_type='side'): initial_conf = get_carry_conf(arm, grasp_type) hsr = create_hsr() set_arm_conf(hsr, arm, initial_conf) table, cabbage, sink, stove = create_kitchen() d = 0.1 sink_button = create_box(d, d, d, color=(0, 0, 0, 1)) set_pose(sink_button, ((0, 2-(.5+d)/2, .7-d/2), z_rotation(np.pi/2))) stove_button = create_box(d, d, d, color=(0, 0, 0, 1)) set_pose(stove_button, ((0, -2+(.5+d)/2, .7-d/2), z_rotation(-np.pi/2))) return Problem(robot=hsr, movable=[cabbage], arms=[arm], grasp_types=[grasp_type], surfaces=[table, sink, stove], sinks=[sink], stoves=[stove], buttons=[(sink_button, sink), (stove_button, stove)], goal_conf=get_pose(hsr), goal_holding=[(arm, cabbage)], goal_cooked=[cabbage]) PROBLEMS = [ holding_problem, stacking_problem, cleaning_problem, cooking_problem, cleaning_button_problem, cooking_button_problem, ]
9,432
Python
34.197761
116
0.590543
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/hsrb_primitives.py
from __future__ import print_function import os import copy import json import time import random import numpy as np import pybullet as p from itertools import islice, count from scipy.spatial.transform import Rotation as R from .ikfast.hsrb.ik import is_ik_compiled, hsr_inverse_kinematics from .hsrb_utils import ( # Getter get_gripper_joints, get_carry_conf, get_top_grasps, get_side_grasps, get_x_presses, \ get_group_joints, get_gripper_link, get_arm_joints, get_group_conf, get_base_joints, \ get_base_arm_joints, get_torso_joints, get_base_torso_arm_joints, \ # Utility open_arm, arm_conf, base_arm_conf, learned_pose_generator, joints_from_names, compute_grasp_width, \ # Constant HSR_TOOL_FRAMES, HSR_GROUPS, HSR_GRIPPER_ROOTS, TOP_HOLDING_ARM, SIDE_HOLDING_ARM, GET_GRASPS) from .utils import ( # Getter get_joint_positions, get_distance, get_min_limit, get_relative_pose, get_aabb, get_unit_vector, \ get_moving_links, get_custom_limits, get_custom_limits_with_base, get_body_name, get_bodies, get_extend_fn, \ get_name, get_link_pose, get_point, get_pose, \ # Setter set_pose, is_placement, set_joint_positions, is_inserted, \ # Utility invert, multiply, all_between, pairwise_collision, sample_placement, sample_insertion, \ waypoints_from_path, unit_quat, plan_base_motion, plan_joint_motion, base_values_from_pose, \ pose_from_base_values, uniform_pose_generator, add_fixed_constraint, remove_debug, \ remove_fixed_constraint, disable_real_time, enable_real_time, enable_gravity, step_simulation, \ joint_controller_hold, add_segments, link_from_name, interpolate_poses, plan_linear_motion, \ plan_direct_joint_motion, has_gui, create_attachment, wait_for_duration, wait_if_gui, flatten_links, create_marker, \ BodySaver, Attachment, \ # Constant BASE_LINK) BASE_EXTENT = 3.5 BASE_LIMITS = (-BASE_EXTENT*np.ones(2), BASE_EXTENT*np.ones(2)) GRASP_LENGTH = 0.03 APPROACH_DISTANCE = 0.1 + GRASP_LENGTH SELF_COLLISIONS = False ################################################## def get_base_limits(): return BASE_LIMITS ################################################## class Pose(object): num = count() def __init__(self, body, value=None, support=None, extra=None, init=False): self.body = body if value is None: value = get_pose(self.body) self.value = tuple(value) self.support = support self.extra= extra self.init = init self.index = next(self.num) @property def bodies(self): return flatten_links(self.body) def assign(self): set_pose(self.body, self.value) def iterate(self): yield self def to_base_conf(self): values = base_values_from_pose(self.value) return Conf(self.body, range(len(values)), values) def __repr__(self): index = self.index return 'p{}'.format(index) class Grasp(object): def __init__(self, grasp_type, body, value, approach, carry): self.grasp_type = grasp_type self.body = body self.value = tuple(value) self.approach = tuple(approach) self.carry = tuple(carry) def get_attachment(self, robot, arm): tool_link = link_from_name(robot, HSR_TOOL_FRAMES[arm]) return Attachment(robot, tool_link, self.value, self.body) def __repr__(self): return 'g{}'.format(id(self) % 1000) class Conf(object): def __init__(self, body, joints, values=None, init=False): self.body = body self.joints = joints if values is None: values = get_joint_positions(self.body, self.joints) self.values = tuple(values) self.init = init @property def bodies(self): return flatten_links(self.body, get_moving_links(self.body, self.joints)) def assign(self): set_joint_positions(self.body, self.joints, self.values) def iterate(self): yield self def __repr__(self): return 'q{}'.format(id(self) % 1000) class State(object): def __init__(self, attachments={}, cleaned=set(), cooked=set()): self.poses = {body: Pose(body, get_pose(body)) for body in get_bodies() if body not in attachments} self.grasps = {} self.attachments = attachments self.cleaned = cleaned self.cooked = cooked def assign(self): for attachment in self.attachments.values(): attachment.assign() ##################################### class Command(object): def control(self, dt=0): raise NotImplementedError() def apply(self, state, **kwargs): raise NotImplementedError() def iterate(self): raise NotImplementedError() class Commands(object): def __init__(self, state, savers=[], commands=[]): self.state = state self.savers = tuple(savers) self.commands = tuple(commands) def assign(self): for saver in self.savers: saver.restore() return copy.copy(self.state) def apply(self, state, **kwargs): for command in self.commands: for result in command.apply(state, **kwargs): yield result def __repr__(self): return 'c{}'.format(id(self) % 1000) ##################################### class Trajectory(Command): _draw = False def __init__(self, path): self.path = tuple(path) def apply(self, state, sample=1): handles = add_segments(self.to_points()) if self._draw and has_gui() else [] for conf in self.path[::sample]: conf.assign() yield end_conf = self.path[-1] if isinstance(end_conf, Pose): state.poses[end_conf.body] = end_conf for handle in handles: remove_debug(handle) def control(self, dt=0, **kwargs): for conf in self.path: if isinstance(conf, Pose): conf = conf.to_base_conf() for _ in joint_controller_hold(conf.body, conf.joints, conf.values): step_simulation() time.sleep(dt) def to_points(self, link=BASE_LINK): points = [] for conf in self.path: with BodySaver(conf.body): conf.assign() point = np.array(get_group_conf(conf.body, 'base')) point[2] = 0 point += 1e-2*np.array([0, 0, 1]) if not (points and np.allclose(points[-1], point, atol=1e-3, rtol=0)): points.append(point) points = get_target_path(self) return waypoints_from_path(points) def distance(self, distance_fn=get_distance): total = 0. for q1, q2 in zip(self.path, self.path[1:]): total += distance_fn(q1.values, q2.values) return total def iterate(self): for conf in self.path: yield conf def reverse(self): return Trajectory(reversed(self.path)) def __repr__(self): d = 0 if self.path: conf = self.path[0] d = 3 if isinstance(conf, Pose) else len(conf.joints) return 't({},{})'.format(d, len(self.path)) def create_trajectory(robot, joints, path): return Trajectory(Conf(robot, joints, q) for q in path) ##################################### Actions class GripperCommand(Command): def __init__(self, robot, arm, position, teleport=False): self.robot = robot self.arm = arm self.position = position self.teleport = teleport def apply(self, state, **kwargs): joints = get_gripper_joints(self.robot, self.arm) start_conf = get_joint_positions(self.robot, joints) end_conf = [self.position] * len(joints) if self.teleport: path = [start_conf, end_conf] else: extend_fn = get_extend_fn(self.robot, joints) path = [start_conf] + list(extend_fn(start_conf, end_conf)) for positions in path: set_joint_positions(self.robot, joints, positions) yield positions def control(self, **kwargs): joints = get_gripper_joints(self.robot, self.arm) positions = [self.position]*len(joints) control_mode = p.TORQUE_CONTROL for _ in joint_controller_hold(self.robot, joints, control_mode, positions): yield def __repr__(self): return '{}({},{},{})'.format(self.__class__.__name__, get_body_name(self.robot), self.arm, self.position) class Attach(Command): vacuum = True def __init__(self, robot, arm, grasp, body): self.robot = robot self.arm = arm self.grasp = grasp self.body = body self.link = link_from_name(self.robot, HSR_TOOL_FRAMES.get(self.arm, self.arm)) def assign(self): gripper_pose = get_link_pose(self.robot, self.link) body_pose = multiply(gripper_pose, self.grasp.value) set_pose(self.body, body_pose) def apply(self, state, **kwargs): state.attachments[self.body] = create_attachment(self.robot, self.link, self.body) state.grasps[self.body] = self.grasp del state.poses[self.body] yield def control(self, dt=0, **kwargs): if self.vacuum: add_fixed_constraint(self.body, self.robot, self.link) else: gripper_name = '{}_gripper'.format(self.arm) joints = joints_from_names(self.robot, HSR_GROUPS[gripper_name]) values = [get_min_limit(self.robot, joint) for joint in joints] for _ in joint_controller_hold(self.robot, joints, values): step_simulation() time.sleep(dt) def __repr__(self): return '{}({},{},{})'.format(self.__class__.__name__, get_body_name(self.robot), self.arm, get_name(self.body)) class Detach(Command): def __init__(self, robot, arm, body): self.robot = robot self.arm = arm self.body = body self.link = link_from_name(self.robot, HSR_TOOL_FRAMES.get(self.arm, self.arm)) def apply(self, state, **kwargs): del state.attachments[self.body] state.poses[self.body] = Pose(self.body, get_pose(self.body)) del state.grasps[self.body] yield def control(self, **kwargs): remove_fixed_constraint(self.body, self.robot, self.link) def __repr__(self): return '{}({},{},{})'.format(self.__class__.__name__, get_body_name(self.robot), self.arm, get_name(self.body)) ##################################### Additional Actions class Clean(Command): def __init__(self, body): self.body = body def apply(self, state, **kwargs): state.cleaned.add(self.body) self.control() yield def control(self, **kwargs): p.addUserDebugText('Cleaned', textPosition=(0, 0, .25), textColorRGB=(0,0,1), lifeTime=0, parentObjectUniqueId=self.body) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) class Cook(Command): def __init__(self, body): self.body = body def apply(self, state, **kwargs): state.cleaned.remove(self.body) state.cooked.add(self.body) self.control() yield def control(self, **kwargs): p.addUserDebugText('Cooked', textPosition=(0, 0, .5), textColorRGB=(1,0,0), lifeTime=0, parentObjectUniqueId=self.body) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) ##################################### Streams def get_stable_gen(problem, collisions=True, **kwargs): # Sample place pose obstacles = problem.fixed if collisions else [] extra = 'place' def gen(body, surface): if surface is None: surfaces = problem.surfaces else: surfaces = [surface] while True: surface = random.choice(surfaces) body_pose = sample_placement(body, surface, **kwargs) if body_pose is None: break p = Pose(body, body_pose, surface, extra) p.assign() # If the obstacles is not included in the surface and body, check pairwise collision between body. if not any(pairwise_collision(body, obst) for obst in obstacles if obst not in {body, surface}): yield (p,) return gen def get_insert_gen(problem, collisions=True, **kwargs): # Sample insert pose obstacles = problem.fixed if collisions else [] extra = 'insert' def gen(body, hole): if hole is None: holes = problem.holes else: holes = [hole] while True: hole = random.choice(holes) body_pose = sample_insertion(body, hole, **kwargs) if body_pose is None: break p = Pose(body, body_pose, hole, extra) p.assign() # If the obstacles is not included in the surface and body, check pairwise collision between body. if not any(pairwise_collision(body, obst) for obst in obstacles if obst not in {body, hole}): yield (p,) return gen def get_grasp_gen(problem, collisions=True, randomize=False): # Sample pick pose for grasp_type in problem.grasp_types: if grasp_type not in GET_GRASPS: raise ValueError('Unexpected grasp type:', grasp_type) def fn(body): grasps = [] arm = 'arm' if 'top' in problem.grasp_types: approach_vector = APPROACH_DISTANCE * get_unit_vector([1, 0, 0]) grasps.extend(Grasp('top', body, g, multiply((approach_vector, unit_quat()), g), TOP_HOLDING_ARM) for g in get_top_grasps(body, grasp_length=GRASP_LENGTH)) if 'side' in problem.grasp_types: approach_vector = APPROACH_DISTANCE * get_unit_vector([0, -1, 0]) grasps.extend(Grasp('side', body, g, multiply((approach_vector, unit_quat()), g), SIDE_HOLDING_ARM) for g in get_side_grasps(body, grasp_length=GRASP_LENGTH)) filtered_grasps = [] for grasp in grasps: grasp_width = compute_grasp_width(problem.robot, arm, body, grasp.value) if collisions else 0.125 # TODO: modify if grasp_width is not None: grasp.grasp_width = grasp_width filtered_grasps.append(grasp) if randomize: random.shuffle(filtered_grasps) return [(g,) for g in filtered_grasps] return fn def get_tool_from_root(robot, arm): root_link = link_from_name(robot, HSR_GRIPPER_ROOTS[arm]) tool_link = link_from_name(robot, HSR_TOOL_FRAMES[arm]) return get_relative_pose(robot, root_link, tool_link) def iterate_approach_path(robot, arm, gripper, pose, grasp, body=None): tool_from_root = get_tool_from_root(robot, arm) grasp_pose = multiply(pose.value, invert(grasp.value)) approach_pose = multiply(pose.value, invert(grasp.approach)) for tool_pose in interpolate_poses(grasp_pose, approach_pose): set_pose(gripper, multiply(tool_pose, tool_from_root)) if body is not None: set_pose(body, multiply(tool_pose, grasp.value)) yield def get_ir_sampler(problem, custom_limits={}, max_attempts=25, collisions=True, learned=False): # Sample move_base pose robot = problem.robot obstacles = problem.fixed if collisions else [] gripper = problem.get_gripper() def gen_fn(arm, obj, pose, grasp): pose.assign() approach_obstacles = {obst for obst in obstacles if not is_placement(obj, obst)} for _ in iterate_approach_path(robot, arm, gripper, pose, grasp, body=obj): if any(pairwise_collision(gripper, b) or pairwise_collision(obj, b) for b in approach_obstacles): return gripper_pose = pose.value # multiply(pose.value, invert(grasp.value)) default_conf = arm_conf(arm, grasp.carry) arm_joints = get_arm_joints(robot, arm) base_joints = get_group_joints(robot, 'base') if learned: base_generator = learned_pose_generator(robot, gripper_pose, arm=arm, grasp_type=grasp.grasp_type) else: base_generator = uniform_pose_generator(robot, gripper_pose) lower_limits, upper_limits = get_custom_limits(robot, base_joints, custom_limits) while True: for base_conf in islice(base_generator, max_attempts): if not all_between(lower_limits, base_conf, upper_limits): continue bq = Conf(robot, base_joints, base_conf) pose.assign() bq.assign() set_joint_positions(robot, arm_joints, default_conf) if any(pairwise_collision(robot, b) for b in obstacles + [obj]): continue yield (bq,) break else: yield None return gen_fn def get_ik_fn(problem, custom_limits={}, collisions=True, teleport=False): robot = problem.robot obstacles = problem.fixed if collisions else [] if is_ik_compiled(): print('Using ikfast for inverse kinematics') else: print('Using pybullet for inverse kinematics') saved_place_conf = {} saved_default_conf = {} def fn(arm, obj, pose, grasp, base_conf): # Obstacles approach_obstacles = {obst for obst in obstacles if not is_placement(obj, obst)} # HSR joints arm_joints = get_arm_joints(robot, arm) base_joints = get_base_joints(robot, arm) base_arm_joints = get_base_arm_joints(robot, arm) # Select grasp_type if 'shaft' in str(problem.body_names[obj]): grasp_type = 'side' elif 'gear' in str(problem.body_names[obj]): grasp_type = 'bottom' # Set planning parameters resolutions = 0.05 * np.ones(len(base_arm_joints)) weights = [10, 10, 10, 50, 50, 50, 50, 50] if pose.extra == 'place': # Default confs default_arm_conf = get_carry_conf(arm, grasp_type) default_base_conf = get_joint_positions(robot, base_joints) default_base_arm_conf = [*default_base_conf, *default_arm_conf] pose.assign() base_conf.assign() attachment = grasp.get_attachment(problem.robot, arm) attachments = {attachment.child: attachment} # Get place pose and approach pose from deterministic_place place_pose, approach_pose = deterministic_place(obj, pose) # Set position to default configuration for grasp action set_joint_positions(robot, base_arm_joints, default_base_arm_conf) place_conf = hsr_inverse_kinematics(robot, arm, place_pose, custom_limits=custom_limits) if (place_conf is None) or any(pairwise_collision(robot, b) for b in obstacles): return None approach_conf = hsr_inverse_kinematics(robot, arm, approach_pose, custom_limits=custom_limits) if (approach_conf is None) or any(pairwise_collision(robot, b) for b in obstacles + [obj]): return None approach_conf = get_joint_positions(robot, base_arm_joints) # Plan joint motion for grasp place_path = plan_joint_motion(robot, base_arm_joints, place_conf, attachments=attachments.values(), obstacles=approach_obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions/2., weights=weights, restarts=2, iterations=25, smooth=25) if place_path is None: print('Place path failure') return None set_joint_positions(robot, base_arm_joints, default_base_arm_conf) saved_default_conf[str(obj)] = default_base_conf # Plan joint motion for approaching approach_path = plan_direct_joint_motion(robot, base_arm_joints, approach_conf, attachments=attachments.values(), obstacles=obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions) if approach_path is None: print('Approach path failure') return None # Save place conf set_joint_positions(robot, base_arm_joints, place_conf) saved_place_conf[str(obj)] = place_conf path1 = approach_path mt1 = create_trajectory(robot, base_arm_joints, path1) path2 = place_path mt2 = create_trajectory(robot, base_arm_joints, path2) cmd = Commands(State(attachments=attachments), savers=[BodySaver(robot)], commands=[mt1, mt2]) return (cmd,) elif pose.extra == 'insert': # Default confs default_arm_conf = arm_conf(arm, grasp.carry) default_base_conf = get_joint_positions(robot, base_joints) default_base_arm_conf = [*default_base_conf, *default_arm_conf] pose.assign() base_conf.assign() attachment = grasp.get_attachment(problem.robot, arm) attachments = {attachment.child: attachment} # Set position to default configuration for grasp action set_joint_positions(robot, base_arm_joints, default_base_arm_conf) # Get insert pose and depart pose from deterministic_insert insert_pose, depart_pose = deterministic_insert(obj, pose) depart_conf = hsr_inverse_kinematics(robot, arm, depart_pose, custom_limits=custom_limits) if (depart_conf is None) or any(pairwise_collision(robot, b) for b in obstacles): return None insert_conf = hsr_inverse_kinematics(robot, arm, insert_pose, custom_limits=custom_limits) if (insert_conf is None) or any(pairwise_collision(robot, b) for b in obstacles): return None # Set joints to place_conf place_conf = saved_place_conf[str(obj)] set_joint_positions(robot, base_arm_joints, place_conf) # Plan joint motion for insert action insert_path = plan_joint_motion(robot, base_arm_joints, insert_conf, attachments=attachments.values(), obstacles=approach_obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions/2., weights=weights, restarts=2, iterations=25, smooth=25) if insert_path is None: print('Insert path failure') return None # Set joints to insert_conf set_joint_positions(robot, base_arm_joints, insert_conf) # Plan joint motion for depart action depart_path = plan_direct_joint_motion(robot, base_arm_joints, depart_conf, attachments=attachments.values(), obstacles=obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions) if depart_path is None: print('Depart path failure') return None # Get end position to return return_conf = get_joint_positions(robot, base_arm_joints) # Set end positions to return default_arm_conf = arm_conf(arm, grasp.carry) default_base = saved_default_conf[str(obj)] default_base_arm_conf = [*default_base[:3], *default_arm_conf] set_joint_positions(robot, base_arm_joints, default_base_arm_conf) # Plan joint motion for return action return_path = plan_direct_joint_motion(robot, base_arm_joints, return_conf, attachments=attachments.values(), obstacles=obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions) if return_path is None: print('Return path failure') return None path1 = insert_path mt1 = create_trajectory(robot, base_arm_joints, path1) path2 = depart_path mt2 = create_trajectory(robot, base_arm_joints, path2) path3 = return_path mt3 = create_trajectory(robot, base_arm_joints, path3) cmd = Commands(State(attachments=attachments), savers=[BodySaver(robot)], commands=[mt1, mt2, mt3]) return (cmd,) else: # Default confs default_arm_conf = arm_conf(arm, grasp.carry) default_base_conf = get_joint_positions(robot, base_joints) default_base_arm_conf = [*default_base_conf, *default_arm_conf] pose.assign() base_conf.assign() attachment = grasp.get_attachment(problem.robot, arm) attachments = {attachment.child: attachment} # If pick action, return grasp pose (pose is obtained from PyBullet at initialization) pick_pose, approach_pose = deterministic_pick(obj, pose) # Set position to default configuration for grasp action set_joint_positions(robot, arm_joints, default_arm_conf) pick_conf = hsr_inverse_kinematics(robot, arm, pick_pose, custom_limits=custom_limits) if (pick_conf is None) or any(pairwise_collision(robot, b) for b in obstacles): return None approach_conf = hsr_inverse_kinematics(robot, arm, approach_pose, custom_limits=custom_limits) if (approach_conf is None) or any(pairwise_collision(robot, b) for b in obstacles + [obj]): return None approach_conf = get_joint_positions(robot, base_arm_joints) # Plan joint motion for grasp grasp_path = plan_joint_motion(robot, base_arm_joints, pick_conf, attachments=attachments.values(), obstacles=approach_obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions/2., weights=weights, restarts=2, iterations=25, smooth=25) if grasp_path is None: print('Grasp path failure') return None set_joint_positions(robot, base_arm_joints, default_base_arm_conf) # Plan joint motion for approach approach_path = plan_direct_joint_motion(robot, base_arm_joints, approach_conf, attachments=attachments.values(), obstacles=obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions) if approach_path is None: print('Approach path failure') return None grasp_arm_conf = get_carry_conf(arm, grasp_type) grasp_base_conf = default_base_conf grasp_base_arm_conf = [*grasp_base_conf, *grasp_arm_conf] set_joint_positions(robot, base_arm_joints, approach_conf) # Plan joint motion for return return_path = plan_direct_joint_motion(robot, base_arm_joints, grasp_base_arm_conf, attachments=attachments.values(), obstacles=obstacles, self_collisions=SELF_COLLISIONS, custom_limits=custom_limits, resolutions=resolutions) if return_path is None: print('Return path failure') return None path1 = approach_path mt1 = create_trajectory(robot, base_arm_joints, path1) path2 = grasp_path mt2 = create_trajectory(robot, base_arm_joints, path2) path3 = return_path mt3 = create_trajectory(robot, base_arm_joints, path3) cmd = Commands(State(attachments=attachments), savers=[BodySaver(robot)], commands=[mt1, mt2, mt3]) return (cmd,) return fn def get_ik_ir_gen(problem, max_attempts=25, learned=False, teleport=False, **kwargs): ir_sampler = get_ir_sampler(problem, learned=learned, max_attempts=1, **kwargs) ik_fn = get_ik_fn(problem, teleport=teleport, **kwargs) def gen(*inputs): b, a, p, g = inputs ir_generator = ir_sampler(*inputs) attempts = 0 while True: if max_attempts <= attempts: if not p.init: return attempts = 0 yield None attempts += 1 try: ir_outputs = next(ir_generator) except StopIteration: return if ir_outputs is None: continue ik_outputs = ik_fn(*(inputs + ir_outputs)) if ik_outputs is None: continue print('IK attempts:', attempts) yield ir_outputs + ik_outputs return return gen def get_motion_gen(problem, custom_limits={}, collisions=True, teleport=False, motion_plan=False): robot = problem.robot saver = BodySaver(robot) obstacles = problem.fixed if collisions else [] def fn(bq1, bq2, fluents=[]): saver.restore() bq1.assign() if teleport: path = [bq1, bq2] else: resolutions = 0.05 * np.ones(len(bq2.joints)) raw_path = plan_joint_motion(robot, bq2.joints, bq2.values, attachments=[], obstacles=obstacles, custom_limits=custom_limits, self_collisions=SELF_COLLISIONS, resolutions=resolutions/2., restarts=2, iterations=25, smooth=25) if raw_path is None: print('Failed motion plan!') return None path = [Conf(robot, bq2.joints, q) for q in raw_path] if motion_plan: goal_conf = base_values_from_pose(bq2.value) raw_path = plan_base_motion(robot, goal_conf, BASE_LIMITS, obstacles=obstacles) if raw_path is None: print('Failed motion plan!') return None path = [Pose(robot, pose_from_base_values(q, bq1.value)) for q in raw_path] bt = Trajectory(path) cmd = Commands(State(), savers=[BodySaver(robot)], commands=[bt]) return (cmd,) return fn def accelerate_gen_fn(gen_fn, max_attempts=1): def new_gen_fn(*inputs): generator = gen_fn(*inputs) while True: for i in range(max_attempts): try: output = next(generator) except StopIteration: return if output is not None: print(gen_fn.__name__, i) yield output break return new_gen_fn ################################################## def visualize_traj(path): import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d, Axes3D x_traj = path[0] y_traj = path[1] z_traj = path[2] fig = plt.figure() ax = fig.add_subplot(projection='3d') ax.plot(x_traj, y_traj, z_traj, markersize=5, color='blue', marker='.') plt.show() ################################################## def apply_commands_with_visualization(state, commands, time_step=None, pause=False, **kwargs): x_traj, y_traj, z_traj = [], [], [] for i, command in enumerate(commands): print(i, command) for j, _ in enumerate(command.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) wait_if_gui('Command {}, Step {}) Next?'.format(i, j)) else: wait_for_duration(time_step) ee_pose = get_link_pose(2, link_from_name(2, HSR_TOOL_FRAMES['arm'])) # hsr is 2 (depends on problem) x_traj.append(ee_pose[0][0]) y_traj.append(ee_pose[0][1]) z_traj.append(ee_pose[0][2]) if pause: wait_if_gui() path = [x_traj, y_traj, z_traj] visualize_traj(path) def apply_commands_with_save(state, commands, time_step=None, pause=False, **kwargs): ee_traj = [] joint_traj = [] movable_joints = get_base_arm_joints(2, 'arm') # 8 joints for i, command in enumerate(commands): print(i, command) for j, _ in enumerate(command.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) wait_if_gui('Command {}, Step {}) Next?'.format(i, j)) else: wait_for_duration(time_step) ee_pose = get_link_pose(2, link_from_name(2, HSR_TOOL_FRAMES['arm'])) ee_traj.append(ee_pose) joint_pos = get_joint_positions(2, movable_joints) joint_traj.append(joint_pos) if pause: wait_if_gui() np.save('simulation_ee_traj', ee_traj) np.save('simulation_joint_traj', joint_traj) def apply_commands(state, commands, time_step=None, pause=False, **kwargs): for i, command in enumerate(commands): print(i, command) for j, _ in enumerate(command.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) wait_if_gui('Command {}, Step {}) Next?'.format(i, j)) else: wait_for_duration(time_step) if pause: wait_if_gui() def apply_named_commands(state, commands, time_step=None, pause=False, **kwargs): for action_name, target_object_name, exp_command in commands: print(action_name, target_object_name, exp_command) for command in exp_command: for j, _ in enumerate(command.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) wait_if_gui('Command {}, Step {}) Next?'.format(i, j)) else: wait_for_duration(time_step) if pause: wait_if_gui() ##################################### Debug def control_commands(commands, **kwargs): wait_if_gui('Control?') disable_real_time() enable_gravity() for i, command in enumerate(commands): print(i, command) command.control(*kwargs) ##################################### Test def get_target_point(conf): robot = conf.body link = link_from_name(robot, 'torso_lift_link') with BodySaver(conf.body): conf.assign() lower, upper = get_aabb(robot, link) center = np.average([lower, upper], axis=0) point = np.array(get_group_conf(conf.body, 'base')) point[2] = center[2] return point def get_target_path(trajectory): return [get_target_point(conf) for conf in trajectory.path] def get_cfree_pose_pose_test(collisions=True, **kwargs): def test(b1, p1, b2, p2): if not collisions or (b1 == b2): return True p1.assign() p2.assign() return not pairwise_collision(b1, b2, **kwargs) return test def get_cfree_obj_approach_pose_test(collisions=True): def test(b1, p1, g1, b2, p2): if not collisions or (b1 == b2): return True p2.assign() grasp_pose = multiply(p1.value, invert(g1.value)) approach_pose = multiply(p1.value, invert(g1.approach), g1.value) for obj_pose in interpolate_poses(grasp_pose, approach_pose): set_pose(b1, obj_pose) if pairwise_collision(b1, b2): return False return True return test def get_cfree_approach_pose_test(problem, collisions=True): arm = 'arm' gripper = problem.get_gripper() def test(b1, p1, g1, b2, p2): if not collisions or (b1 == b2): return True p2.assign() for _ in iterate_approach_path(problem.robot, arm, gripper, p1, g1, body=b1): if pairwise_collision(b1, b2) or pairwise_collision(gripper, b2): return False return True return test def get_cfree_traj_pose_test(problem, collisions=True): def test(c, b2, p2): if not collisions: return True state = c.assign() if b2 in state.attachments: return True p2.assign() for _ in c.apply(state): state.assign() for b1 in state.attachments: if pairwise_collision(b1, b2): return False if pairwise_collision(problem.robot, b2): return False return True return test def get_cfree_traj_grasp_pose_test(problem, collisions=True): def test(c, a, b1, g, b2, p2): if not collisions or (b1 == b2): return True state = c.assign() if (b1 in state.attachments) or (b2 in state.attachments): return True p2.assign() grasp_attachment = g.get_attachment(problem.robot, a) for _ in c.apply(state): state.assign() grasp_attachment.assign() if pairwise_collision(b1, b2): return False if pairwise_collision(problem.robot, b2): return False return True return test def get_supported(problem, collisions=True): def test(b, p1, r, p2): return is_placement(b, r) return test def get_inserted(problem, collisions=True): def test(b, p1, r, p2): return is_inserted(b, r) return test BASE_CONSTANT = 1 BASE_VELOCITY = 0.25 def distance_fn(q1, q2): distance = get_distance(q1.values[:2], q2.values[:2]) return BASE_CONSTANT + distance / BASE_VELOCITY def move_cost_fn(t): distance = t.distance(distance_fn=lambda q1, q2: get_distance(q1[:2], q2[:2])) return BASE_CONSTANT + distance / BASE_VELOCITY ##################################### Dataset def calculate_delta_angular(q1, q2): # Transform r1 = R.from_quat(q1) r2 = R.from_quat(q2) # Calculate difference diff = r2 * r1.inv() # Transform difference to euler 'xyz' delta_euler = diff.as_euler('xyz') return delta_euler.tolist() def create_dataset(problem_name, robot, objects, object_names, state, commands, time_step=None, pause=False, **kwargs): movable_joints = get_base_arm_joints(robot, 'arm') # 8 joints gripper_joints = get_gripper_joints(robot, 'arm') # 2 joints whole_body_joints = movable_joints + gripper_joints # 10 joints full_joint_names = ['joint_x', 'joint_y', 'joint_rz', 'arm_lift_joint', 'torso_lift_joint', 'arm_flex_joint', 'head_pan_joint', 'arm_roll_joint', 'head_tilt_joint', 'wrist_flex_joint', 'wrist_roll_joint', 'hand_l_proximal_joint', 'hand_r_proximal_joint', 'hand_l_distal_joint', 'hand_r_distal_joint'] full_joints = joints_from_names(robot, full_joint_names) # 15 joints # Up to what point should I record? skill_clip_index = {'move_base': 0, 'pick': 1, 'place': 1, 'insert': 2} # Prepare trajectory dict for all pose / positions traj = {'robot_pose': [], 'gripper_pose': [], 'ee_pose': [], 'diff_robot_pose': [], 'diff_gripper_pose': [], 'diff_ee_pose': [], 'object_pose': {object_names[obj]: list() for obj in objects}} # Prepare metadata for robot poses and object poses metadata = {'robot_init_pose': [], # robot initial joint positions 'robot_goal_pose': [], # robot final joint positions 'object_init_pose': {object_names[obj]: list() for obj in objects}, # object initial pose 'object_goal_pose': [], # object goal pose 'target_object_name': [], # pick target object's name 'skill_name': []} goal_robot_poses = [] goal_object_poses = [] # Add metadata (init_data) metadata['robot_init_pose'] = get_joint_positions(robot, full_joints) for obj in objects: metadata['object_init_pose'][object_names[obj]] = get_pose(obj) for action_name, target_object_name, command in commands: # Get previous robot joint positions and end effector pose prev_robot_pose = get_joint_positions(robot, whole_body_joints) prev_gripper_pose = get_joint_positions(robot, gripper_joints) prev_ee_pose = get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm'])) command_num = 0 # Execute commands for c in command: for j, _ in enumerate(c.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) else: wait_for_duration(time_step) # Get robot poses (10) robot_pose = get_joint_positions(robot, whole_body_joints) # Get gripper_joint poses (2) gripper_pose = get_joint_positions(robot, gripper_joints) # Get end effector poses (7) ee_pose = get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm'])) # Get diff robot poses (10) diff_robot_pose = tuple(curr_pose - prev_pose for curr_pose, prev_pose in zip(robot_pose, prev_robot_pose)) # Get diff gripper_joint poses (2) diff_gripper_pose = tuple(curr_pose - prev_pose for curr_pose, prev_pose in zip(gripper_pose, prev_gripper_pose)) # Get diff end_effector poses (6) diff_ee_pose = tuple([curr_pos - prev_pos for curr_pos, prev_pos in zip(ee_pose[0], prev_ee_pose[0])] + calculate_delta_angular(ee_pose[1], prev_ee_pose[1])) # Absolute pose / positions traj['robot_pose'].append(robot_pose) traj['gripper_pose'].append(gripper_pose) traj['ee_pose'].append(ee_pose) # Relative pose / positions traj['diff_robot_pose'].append(diff_robot_pose) traj['diff_gripper_pose'].append(diff_gripper_pose) traj['diff_ee_pose'].append(diff_ee_pose) for obj in objects: object_name = object_names[obj] object_pose = get_pose(obj) traj['object_pose'][object_name].append(object_pose) prev_robot_pose = robot_pose prev_gripper_pose = gripper_pose prev_ee_pose = ee_pose # Target object name metadata['target_object_name'].append(target_object_name) metadata['skill_name'].append(action_name) # Save each skill's target robot pose if skill_clip_index[action_name] == command_num: goal_robot_poses.append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) command_num += 1 for obj in objects: if target_object_name == object_names[obj]: goal_object_poses.append(get_pose(obj)) if action_name == 'move_base': goal_object_poses.append(get_pose(0)) # Create dataset trajectory_path = os.path.join(os.environ['PYTHONPATH'].split(':')[1], 'experiments', 'env_3d', 'dataset', problem_name, 'full', 'trajectory') num_traj_files = sum(os.path.isfile(os.path.join(trajectory_path, _name)) for _name in os.listdir(trajectory_path)) metadata_path = os.path.join(os.environ['PYTHONPATH'].split(':')[1], 'experiments', 'env_3d', 'dataset', problem_name, 'full', 'metadata') num_meta_files = sum(os.path.isfile(os.path.join(metadata_path, _name)) for _name in os.listdir(metadata_path)) # File names traj_name = 'trajectory_' + str(num_traj_files) + '.json' metadata_name = 'metadata_' + str(num_meta_files) + '.json' # File paths traj_path = os.path.join(trajectory_path, traj_name) metadata_path = os.path.join(metadata_path, metadata_name) # Save trajectory / metadata with open(traj_path, 'w') as f: json.dump(traj, f) with open(metadata_path, 'w') as f: json.dump(metadata, f) def create_skill_dataset(problem_name, robot, objects, object_names, state, commands, time_step=None, pause=False, **kwargs): movable_joints = get_base_arm_joints(robot, 'arm') # 8 joints gripper_joints = get_gripper_joints(robot, 'arm') # 2 joints whole_body_joints = movable_joints + gripper_joints # 10 joints full_joint_names = ['joint_x', 'joint_y', 'joint_rz', 'arm_lift_joint', 'torso_lift_joint', 'arm_flex_joint', 'head_pan_joint', 'arm_roll_joint', 'head_tilt_joint', 'wrist_flex_joint', 'wrist_roll_joint', 'hand_l_proximal_joint', 'hand_r_proximal_joint', 'hand_l_distal_joint', 'hand_r_distal_joint'] full_joints = joints_from_names(robot, full_joint_names) # 15 joints # Up to what point should I record? skill_record_index = {'move_base': [0, 0], 'pick': [0, 5], 'place': [0, 1], 'insert': [0, 2]} skill_clip_index = {'move_base': 0, 'pick': 1, 'place': 1, 'insert': 2} for action_name, target_object_name, command in commands: # Prepare trajectory dict for all pose / positions traj = {'robot_pose': [], 'gripper_pose': [], 'ee_pose': [], 'diff_robot_pose': [], 'diff_gripper_pose': [], 'diff_ee_pose': [], 'object_pose': {object_names[obj]: list() for obj in objects}} # Prepare metadata for robot poses and object poses metadata = {'robot_init_pose': [], # robot initial joint positions 'robot_goal_pose': [], # robot final joint positions 'robot_target_pose': [], # robot action target pose 'object_init_pose': {object_names[obj]: list() for obj in objects}, # object initial pose 'object_goal_pose': {object_names[obj]: list() for obj in objects}, # object goal pose 'target_object_name': []} # action target object's name # Add metadata (init_data) metadata['robot_init_pose'] = get_joint_positions(robot, full_joints) for obj in objects: metadata['object_init_pose'][object_names[obj]] = get_pose(obj) metadata['target_object_name'] = target_object_name # Get previous robot joint positions and end effector pose prev_robot_pose = get_joint_positions(robot, whole_body_joints) prev_gripper_pose = get_joint_positions(robot, gripper_joints) prev_ee_pose = get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm'])) command_num = 0 # Execute commands for c in command: for j, _ in enumerate(c.apply(state, **kwargs)): state.assign() if j == 0: continue if time_step is None: wait_for_duration(1e-2) else: wait_for_duration(time_step) # Get robot poses (10) robot_pose = get_joint_positions(robot, whole_body_joints) # Get gripper_joint poses (2) gripper_pose = get_joint_positions(robot, gripper_joints) # Get end effector poses (7) ee_pose = get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm'])) # Get diff robot poses (10) diff_robot_pose = tuple(curr_pose - prev_pose for curr_pose, prev_pose in zip(robot_pose, prev_robot_pose)) # Get diff gripper_joint poses (2) diff_gripper_pose = tuple(curr_pose - prev_pose for curr_pose, prev_pose in zip(gripper_pose, prev_gripper_pose)) # Get diff end_effector poses (6) diff_ee_pose = tuple([curr_pos - prev_pos for curr_pos, prev_pos in zip(ee_pose[0], prev_ee_pose[0])] + calculate_delta_angular(ee_pose[1], prev_ee_pose[1])) if skill_record_index[action_name][0] <= command_num and \ skill_record_index[action_name][1] >= command_num: # Absolute pose / positions traj['robot_pose'].append(robot_pose) traj['gripper_pose'].append(gripper_pose) traj['ee_pose'].append(ee_pose) # Relative pose / positions traj['diff_robot_pose'].append(diff_robot_pose) traj['diff_gripper_pose'].append(diff_gripper_pose) traj['diff_ee_pose'].append(diff_ee_pose) for obj in objects: object_name = object_names[obj] object_pose = get_pose(obj) traj['object_pose'][object_name].append(object_pose) prev_robot_pose = robot_pose prev_gripper_pose = gripper_pose prev_ee_pose = ee_pose # Save each skill's target robot pose if skill_clip_index[action_name] == command_num: metadata['robot_target_pose'] = get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm'])) command_num += 1 if pause: wait_if_gui() # Add metadata (goal_data) metadata['robot_goal_pose'] = get_joint_positions(robot, full_joints) for obj in objects: metadata['object_goal_pose'][object_names[obj]] = get_pose(obj) dataset = [action_name, traj] # Create dataset trajectory_path = os.path.join(os.environ['PYTHONPATH'].split(':')[1], 'experiments', 'env_3d', 'dataset', problem_name, action_name, 'trajectory') num_traj_files = sum(os.path.isfile(os.path.join(trajectory_path, _name)) for _name in os.listdir(trajectory_path)) metadata_path = os.path.join(os.environ['PYTHONPATH'].split(':')[1], 'experiments', 'env_3d', 'dataset', problem_name, action_name, 'metadata') num_meta_files = sum(os.path.isfile(os.path.join(metadata_path, _name)) for _name in os.listdir(metadata_path)) # File names traj_name = 'trajectory_' + str(num_traj_files) + '.json' metadata_name = 'metadata_' + str(num_meta_files) + '.json' # File paths traj_path = os.path.join(trajectory_path, traj_name) metadata_path = os.path.join(metadata_path, metadata_name) # Save trajectory / metadata with open(traj_path, 'w') as f: json.dump(dataset, f) with open(metadata_path, 'w') as f: json.dump(metadata, f) def replay_trajectory(robot, objects, object_names, state, commands, **kwargs): # Up to what point should I record? skill_clip_index = {'move_base': 0, 'pick': 0, 'place': 0, 'insert': 2} # Prepare trajectory dict for all pose / positions pick_metadata = {'init_robot_pose': [], 'goal_robot_pose': [], 'target_robot_pose': [], 'target_object_pose': []} place_metadata = {'init_robot_pose': [], 'goal_robot_pose': [], 'target_robot_pose': [], 'target_object_pose': []} insert_metadata = {'init_robot_pose': [], 'goal_robot_pose': [], 'target_robot_pose': [], 'target_object_pose': []} for action_name, target_object_name, command in commands: # Add metadata (init_data) if action_name == 'pick': pick_metadata['init_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) elif action_name == 'place': place_metadata['init_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) elif action_name == 'insert': insert_metadata['init_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) command_num = 0 # Execute commands for c in command: for j, _ in enumerate(c.apply(state, **kwargs)): state.assign() wait_for_duration(1e-3) # Add metadata (target data) if skill_clip_index[action_name] == command_num: if action_name == 'pick': pick_metadata['target_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) elif action_name == 'place': place_metadata['target_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) elif action_name == 'insert': insert_metadata['target_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) command_num += 1 # Add metadata (goal_data) if action_name == 'pick': pick_metadata['goal_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) for obj in objects: if object_names[obj] == target_object_name: pick_metadata['target_object_pose'].append(get_pose(obj)) elif action_name == 'place': place_metadata['goal_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) for obj in objects: if object_names[obj] == target_object_name: place_metadata['target_object_pose'].append(get_pose(obj)) elif action_name == 'insert': insert_metadata['goal_robot_pose'].append(get_link_pose(robot, link_from_name(robot, HSR_TOOL_FRAMES['arm']))) for obj in objects: if object_names[obj] == target_object_name: insert_metadata['target_object_pose'].append(get_pose(obj)) return pick_metadata, place_metadata, insert_metadata ##################################### Custom def deterministic_pick(pose, offset=[0.12, 0.14]): pick_pose = pose.value pick_pose = ((pick_pose[0][0]-offset[0], pick_pose[0][1], pick_pose[0][2]), pick_pose[1]) approach_pose = ((pick_pose[0][0]-offset[1], pick_pose[0][1], pick_pose[0][2]), pick_pose[1]) grasp_euler = np.array((np.pi/2, np.pi/2, 0.0)) grasp_quat = R.from_euler('zyx', grasp_euler).as_quat() pick_pose = (pick_pose[0], grasp_quat) approach_pose = (approach_pose[0], grasp_quat) return pick_pose, approach_pose def deterministic_place(pose, offset=[0.12, 0.0]): place_pose = pose.value place_pose = ((place_pose[0][0]-offset[0], place_pose[0][1], place_pose[0][2]), place_pose[1]) approach_pose = ((place_pose[0][0]-offset[1], place_pose[0][1], place_pose[0][2]), place_pose[1]) grasp_euler = np.array((np.pi/2, np.pi/2, 0.0)) grasp_quat = R.from_euler('zyx', grasp_euler).as_quat() place_pose = (place_pose[0], grasp_quat) approach_pose = (approach_pose[0], grasp_quat) return place_pose, approach_pose def deterministic_insert(pose, offset=[0.12, 0.14]): insert_pose = pose.value insert_pose = ((insert_pose[0][0]-offset[0], insert_pose[0][1], insert_pose[0][2]), insert_pose[1]) depart_pose = ((insert_pose[0][0]-offset[1], insert_pose[0][1], insert_pose[0][2]), insert_pose[1]) grasp_euler = np.array((np.pi/2, np.pi/2, 0.0)) grasp_quat = R.from_euler('zyx', grasp_euler).as_quat() insert_pose = (insert_pose[0], grasp_quat) depart_pose = (depart_pose[0], grasp_quat) return insert_pose, depart_pose
59,348
Python
40.590049
132
0.54632
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/utils.py
from __future__ import print_function import os import sys import time import math import json import random import shutil import pstats import signal import pickle import inspect import trimesh import colorsys import platform import datetime import cProfile import collections import pybullet_data import numpy as np import pybullet as p import pybullet_utils.bullet_client as bc from collections import defaultdict, deque, namedtuple from itertools import product, combinations, count, cycle, islice from multiprocessing import TimeoutError from contextlib import contextmanager from scipy.spatial.transform import Rotation as R from .transformations import quaternion_from_matrix, unit_vector, euler_from_quaternion, quaternion_slerp directory = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.join(directory, '../motion')) from motion_planners.rrt_connect import birrt from motion_planners.meta import direct_path try: user_input = raw_input except NameError: user_input = input INF = np.inf PI = np.pi EPSILON = 1e-6 DEFAULT_TIME_STEP = 1./240. Interval = namedtuple('Interval', ['lower', 'upper']) UNIT_LIMITS = Interval(0., 1.) CIRCULAR_LIMITS = Interval(-0.01, 0.01) UNBOUNDED_LIMITS = Interval(-INF, INF) ##################################### # Models # Robots MODEL_DIRECTORY = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'models/')) ROOMBA_URDF = 'models/turtlebot/roomba.urdf' TURTLEBOT_URDF = 'models/turtlebot/turtlebot_holonomic.urdf' DRAKE_IIWA_URDF = 'models/drake/iiwa_description/urdf/iiwa14_polytope_collision.urdf' WSG_50_URDF = 'models/drake/wsg_50_description/urdf/wsg_50_mesh_visual.urdf' # wsg_50 | wsg_50_mesh_visual | wsg_50_mesh_collision PANDA_HAND_URDF = "models/franka_description/robots/hand.urdf" PANDA_ARM_URDF = "models/franka_description/robots/panda_arm_hand.urdf" # PyBullet Robots KUKA_IIWA_URDF = 'kuka_iiwa/model.urdf' KUKA_IIWA_GRIPPER_SDF = 'kuka_iiwa/kuka_with_gripper.sdf' R2D2_URDF = 'r2d2.urdf' MINITAUR_URDF = 'quadruped/minitaur.urdf' HUMANOID_MJCF = 'mjcf/humanoid.xml' HUSKY_URDF = 'husky/husky.urdf' RACECAR_URDF = 'racecar/racecar.urdf' # racecar_differential.urdf PR2_GRIPPER = 'pr2_gripper.urdf' PANDA_URDF = 'franka_panda/panda.urdf' # PyBullet wsg50 robots WSG_GRIPPER = 'gripper/wsg50_one_motor_gripper_new.sdf' # PyBullet Objects KIVA_SHELF_SDF = 'kiva_shelf/model.sdf' FLOOR_URDF = 'short_floor.urdf' TABLE_URDF = 'table/table.urdf' # Objects SMALL_BLOCK_URDF = 'models/drake/objects/block_for_pick_and_place.urdf' BLOCK_URDF = 'models/drake/objects/block_for_pick_and_place_mid_size.urdf' SINK_URDF = 'models/sink.urdf' STOVE_URDF = 'models/stove.urdf' ##################################### # I/O SEPARATOR = '\n' + 50*'-' + '\n' inf_generator = count List = lambda *args: list(args) Tuple = lambda *args: tuple(args) def empty_sequence(): return iter([]) def irange(start, end=None, step=1): if end is None: end = start start = 0 n = start while n < end: yield n n += step def count_until(max_iterations=INF, max_time=INF): start_time = time.time() assert (max_iterations < INF) or (max_time < INF) for iteration in irange(max_iterations): if elapsed_time(start_time) >= max_time: break yield iteration def print_separator(n=50): print('\n' + n*'-' + '\n') def is_remote(): return 'SSH_CONNECTION' in os.environ def is_darwin(): return platform.system() == 'Darwin' def get_python_version(): return sys.version_info[0] def read(filename): with open(filename, 'r') as f: return f.read() def write(filename, string): with open(filename, 'w') as f: f.write(string) def read_pickle(filename): # Can sometimes read pickle3 from python2 by calling twice with open(filename, 'rb') as f: try: return pickle.load(f) except UnicodeDecodeError as e: return pickle.load(f, encoding='latin1') def write_pickle(filename, data): with open(filename, 'wb') as f: pickle.dump(data, f) def read_json(path): return json.loads(read(path)) def write_json(path, data): with open(path, 'w') as f: json.dump(data, f, indent=2, sort_keys=True) def safe_remove(path): if os.path.exists(path): if os.path.isdir(path): shutil.rmtree(path) else: os.remove(path) def ensure_dir(f): d = os.path.dirname(f) if not os.path.exists(d): os.makedirs(d) def list_paths(directory): return sorted(os.path.abspath(os.path.join(directory, filename)) for filename in os.listdir(directory)) ################################################## def safe_zip(sequence1, sequence2): sequence1, sequence2 = list(sequence1), list(sequence2) assert len(sequence1) == len(sequence2) return list(zip(sequence1, sequence2)) def get_pairs(sequence): sequence = list(sequence) return safe_zip(sequence[:-1], sequence[1:]) def get_wrapped_pairs(sequence): sequence = list(sequence) return safe_zip(sequence, sequence[1:] + sequence[:1]) def clip(value, min_value=-INF, max_value=+INF): return min(max(min_value, value), max_value) def randomize(iterable): sequence = list(iterable) random.shuffle(sequence) return sequence def get_random_seed(): return random.getstate()[1][1] def get_numpy_seed(): return np.random.get_state()[1][0] def set_random_seed(seed=None): if seed is not None: random.seed(seed) def wrap_numpy_seed(seed): return seed % (2**32) def set_numpy_seed(seed=None): # These generators are different and independent if seed is not None: np.random.seed(wrap_numpy_seed(seed)) DATE_FORMAT = '%y-%m-%d_%H-%M-%S' def get_date(): return datetime.datetime.now().strftime(DATE_FORMAT) def implies(p1, p2): return not p1 or p2 def roundrobin(*iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" pending = len(iterables) nexts = cycle(iter(it).__next__ for it in iterables) while pending: try: for next in nexts: yield next() except StopIteration: pending -= 1 nexts = cycle(islice(nexts, pending)) def chunks(sequence, n=1): for i in range(0, len(sequence), n): yield sequence[i:i + n] def get_function_name(depth=1): return inspect.stack()[depth][3] def load_yaml(path): import yaml with open(path, 'r') as f: try: return yaml.safe_load(f) except yaml.YAMLError as exc: raise exc def flatten(iterable_of_iterables): return (item for iterables in iterable_of_iterables for item in iterables) def find(test, sequence): for item in sequence: if test(item): return item return None def merge_dicts(*args): result = {} for d in args: result.update(d) return result def str_from_object(obj): if type(obj) in [list]: return '[{}]'.format(', '.join(str_from_object(item) for item in obj)) if type(obj) in [tuple]: return '({})'.format(', '.join(str_from_object(item) for item in obj)) if type(obj) in [set, frozenset]: return '{{{}}}'.format(', '.join(sorted(str_from_object(item) for item in obj))) if type(obj) in [dict, defaultdict]: return '{{{}}}'.format(', '.join('{}: {}'.format(*pair) for pair in sorted( tuple(map(str_from_object, pair)) for pair in obj.items()))) return str(obj) def safe_sample(collection, k=1): collection = list(collection) if len(collection) <= k: return collection return random.sample(collection, k) class OrderedSet(collections.OrderedDict, collections.MutableSet): def __init__(self, seq=()): self.update(seq) def update(self, *args, **kwargs): if kwargs: raise TypeError('update() takes no keyword arguments') for s in args: for e in s: self.add(e) def add(self, elem): self[elem] = None def discard(self, elem): self.pop(elem, None) def __le__(self, other): return all(e in other for e in self) def __lt__(self, other): return self <= other and self != other def __ge__(self, other): return all(e in self for e in other) def __gt__(self, other): return self >= other and self != other def __repr__(self): return 'OrderedSet([%s])' % (', '.join(map(repr, self.keys()))) def __str__(self): return '{%s}' % (', '.join(map(repr, self.keys()))) difference = property(lambda self: self.__sub__) difference_update = property(lambda self: self.__isub__) intersection = property(lambda self: self.__and__) intersection_update = property(lambda self: self.__iand__) issubset = property(lambda self: self.__le__) issuperset = property(lambda self: self.__ge__) symmetric_difference = property(lambda self: self.__xor__) symmetric_difference_update = property(lambda self: self.__ixor__) union = property(lambda self: self.__or__) ################################################## BYTES_PER_KILOBYTE = math.pow(2, 10) BYTES_PER_GIGABYTE = math.pow(2, 30) KILOBYTES_PER_GIGABYTE = BYTES_PER_GIGABYTE / BYTES_PER_KILOBYTE def get_memory_in_kb(): import psutil process = psutil.Process(os.getpid()) pmem = process.memory_info() return pmem.vms / BYTES_PER_KILOBYTE def raise_timeout(signum, frame): raise TimeoutError() @contextmanager def timeout(duration): assert 0 < duration if duration == INF: yield return # Register a function to raise a TimeoutError on the signal signal.signal(signal.SIGALRM, raise_timeout) # Schedule the signal to be sent after ``duration`` signal.alarm(int(math.ceil(duration))) try: yield except TimeoutError as e: print('Timeout after {} sec'.format(duration)) pass finally: # Unregister the signal so it won't be triggered # if the timeout is not reached signal.signal(signal.SIGALRM, signal.SIG_IGN) def log_time(method): """ A decorator for methods which will time the method and then emit a log.debug message with the method name and how long it took to execute. """ import logging log = logging.getLogger() def timed(*args, **kwargs): tic = now() result = method(*args, **kwargs) log.debug('%s executed in %.4f seconds.', method.__name__, now() - tic) return result timed.__name__ = method.__name__ timed.__doc__ = method.__doc__ return timed def cached_fn(fn, cache=True, **global_kargs): def normal(*args, **local_kwargs): kwargs = dict(global_kargs) kwargs.update(local_kwargs) return fn(*args, **kwargs) if not cache: return normal @cache_decorator def wrapped(*args, **local_kwargs): return normal(*args, **local_kwargs) return wrapped def cache_decorator(function): """ A decorator for class methods, replaces @property but will store and retrieve function return values in object cache. Parameters ------------ function : method This is used as a decorator: ``` @cache_decorator def foo(self, things): return 'happy days' ``` """ from functools import wraps # use wraps to preserve docstring @wraps(function) def get_cached(*args, **kwargs): """ Only execute the function if its value isn't stored in cache already. """ self = args[0] # use function name as key in cache name = function.__name__ # do the dump logic ourselves to avoid # verifying cache twice per call self._cache.verify() # access cache dict to avoid automatic validation # since we already called cache.verify manually if name in self._cache.cache: # already stored so return value return self._cache.cache[name] # value not in cache so execute the function value = function(*args, **kwargs) # store the value if self._cache.force_immutable and hasattr( value, 'flags') and len(value.shape) > 0: value.flags.writeable = False self._cache.cache[name] = value return value # all cached values are also properties # so they can be accessed like value attributes # rather than functions return property(get_cached) ##################################### class HideOutput(object): # https://stackoverflow.com/questions/5081657/how-do-i-prevent-a-c-shared-library-to-print-on-stdout-in-python # https://stackoverflow.com/questions/4178614/suppressing-output-of-module-calling-outside-library # https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python/22434262#22434262 ''' A context manager that block stdout for its scope, usage: with HideOutput(): os.system('ls -l') ''' DEFAULT_ENABLE = True def __init__(self, enable=None): if enable is None: enable = self.DEFAULT_ENABLE self.enable = enable if not self.enable: return sys.stdout.flush() self._origstdout = sys.stdout self._oldstdout_fno = os.dup(sys.stdout.fileno()) self._devnull = os.open(os.devnull, os.O_WRONLY) def __enter__(self): if not self.enable: return self.fd = 1 #self.fd = sys.stdout.fileno() self._newstdout = os.dup(self.fd) os.dup2(self._devnull, self.fd) os.close(self._devnull) sys.stdout = os.fdopen(self._newstdout, 'w') def __exit__(self, exc_type, exc_val, exc_tb): if not self.enable: return sys.stdout.close() sys.stdout = self._origstdout sys.stdout.flush() os.dup2(self._oldstdout_fno, self.fd) os.close(self._oldstdout_fno) # Added ##################################### # Colors RGB = namedtuple('RGB', ['red', 'green', 'blue']) RGBA = namedtuple('RGBA', ['red', 'green', 'blue', 'alpha']) MAX_RGB = 2**8 - 1 RED = RGBA(1, 0, 0, 1) GREEN = RGBA(0, 1, 0, 1) BLUE = RGBA(0, 0, 1, 1) BLACK = RGBA(0, 0, 0, 1) WHITE = RGBA(1, 1, 1, 1) SKIN = RGBA(0.996, 0.8627, 0.7412, 1) BROWN = RGBA(0.396, 0.263, 0.129, 1) TAN = RGBA(0.824, 0.706, 0.549, 1) LIGHT_GREY = (0.7, 0.7, 0.7, 1.) GREY = RGBA(0.5, 0.5, 0.5, 1) YELLOW = RGBA(1, 1, 0, 1) TRANSPARENT = RGBA(0, 0, 0, 0.001) SHADOW = RGBA(0.1, 0.1, 0.1, 0.3) ACHROMATIC_COLORS = { 'white': WHITE, 'grey': GREY, 'black': BLACK, } CHROMATIC_COLORS = { 'red': RED, 'green': GREEN, 'blue': BLUE, } COLOR_FROM_NAME = merge_dicts(ACHROMATIC_COLORS, CHROMATIC_COLORS) def remove_alpha(color): return RGB(*color[:3]) def apply_alpha(color, alpha=1.): if color is None: return None red, green, blue = color[:3] return RGBA(red, green, blue, alpha) def spaced_colors(n, s=1, v=1): return [RGB(*colorsys.hsv_to_rgb(h, s, v)) for h in np.linspace(0, 1, n, endpoint=False)] ##################################### # Savers class Saver(object): def save(self): pass def restore(self): raise NotImplementedError() def __enter__(self): self.save() def __exit__(self, type, value, traceback): self.restore() class ClientSaver(Saver): def __init__(self, new_client=None): self.client = CLIENT if new_client is not None: set_client(new_client) def restore(self): set_client(self.client) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.client) class VideoSaver(Saver): def __init__(self, path): self.path = path if path is None: self.log_id = None else: name, ext = os.path.splitext(path) assert ext == '.mp4' # STATE_LOGGING_PROFILE_TIMINGS, STATE_LOGGING_ALL_COMMANDS # p.submitProfileTiming('pythontest") self.log_id = p.startStateLogging(p.STATE_LOGGING_VIDEO_MP4, fileName=path, physicsClientId=CLIENT) def restore(self): if self.log_id is not None: p.stopStateLogging(self.log_id) print('Saved', self.path) class Profiler(Saver): fields = ['tottime', 'cumtime', None] def __init__(self, field='tottime', num=10): assert field in self.fields self.field = field self.num = num if field is None: return self.pr = cProfile.Profile() def save(self): if self.field is None: return self.pr.enable() return self.pr def restore(self): if self.field is None: return self.pr.disable() stream = None stats = pstats.Stats(self.pr, stream=stream).sort_stats(self.field) # TODO: print multiple stats.print_stats(self.num) return stats ##################################### class PoseSaver(Saver): def __init__(self, body, pose=None): self.body = body if pose is None: pose = get_pose(self.body) self.pose = pose self.velocity = get_velocity(self.body) def apply_mapping(self, mapping): self.body = mapping.get(self.body, self.body) def restore(self): set_pose(self.body, self.pose) set_velocity(self.body, *self.velocity) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) class ConfSaver(Saver): def __init__(self, body, joints=None, positions=None): self.body = body if joints is None: joints = get_movable_joints(self.body) self.joints = joints if positions is None: positions = get_joint_positions(self.body, self.joints) self.positions = positions self.velocities = get_joint_velocities(self.body, self.joints) @property def conf(self): return self.positions def apply_mapping(self, mapping): self.body = mapping.get(self.body, self.body) def restore(self): set_joint_states(self.body, self.joints, self.positions, self.velocities) def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) class BodySaver(Saver): def __init__(self, body, **kwargs): self.body = body self.pose_saver = PoseSaver(body) self.conf_saver = ConfSaver(body, **kwargs) self.savers = [self.pose_saver, self.conf_saver] def apply_mapping(self, mapping): for saver in self.savers: saver.apply_mapping(mapping) def restore(self): for saver in self.savers: saver.restore() def __repr__(self): return '{}({})'.format(self.__class__.__name__, self.body) class WorldSaver(Saver): def __init__(self, bodies=None): if bodies is None: bodies = get_bodies() self.bodies = bodies self.body_savers = [BodySaver(body) for body in self.bodies] def restore(self): for body_saver in self.body_savers: body_saver.restore() ##################################### # Simulation CLIENTS = {} CLIENT = 0 def get_client(client=None): if client is None: return CLIENT return client def set_client(client): global CLIENT CLIENT = client ModelInfo = namedtuple('URDFInfo', ['name', 'path', 'fixed_base', 'scale']) INFO_FROM_BODY = {} def get_model_info(body): key = (CLIENT, body) return INFO_FROM_BODY.get(key, None) def get_urdf_flags(cache=False, cylinder=False): flags = 0 if cache: flags |= p.URDF_ENABLE_CACHED_GRAPHICS_SHAPES if cylinder: flags |= p.URDF_USE_IMPLICIT_CYLINDER return flags def load_pybullet(filename, fixed_base=False, scale=1., **kwargs): with LockRenderer(): if filename.endswith('.urdf'): flags = get_urdf_flags(**kwargs) body = p.loadURDF(filename, useFixedBase=fixed_base, flags=flags, globalScaling=scale, physicsClientId=CLIENT) elif filename.endswith('.sdf'): body = p.loadSDF(filename, physicsClientId=CLIENT) elif filename.endswith('.xml'): body = p.loadMJCF(filename, physicsClientId=CLIENT) elif filename.endswith('.bullet'): body = p.loadBullet(filename, physicsClientId=CLIENT) elif filename.endswith('.obj'): # TODO: fixed_base => mass = 0? body = create_obj(filename, scale=2, **kwargs) elif filename.endswith('.stl'): # TODO: fixed_base => mass = 0? # TODO: fix scale body = create_stl(filename, scale=0.02, **kwargs) else: raise ValueError(filename) INFO_FROM_BODY[CLIENT, body] = ModelInfo(None, filename, fixed_base, scale) return body def load_virtual_model(filename, fixed_base=False, scale=1., **kwargs): with LockRenderer(): if filename.endswith('.urdf'): flags = get_urdf_flags(**kwargs) body = p.loadURDF(filename, useFixedBase=fixed_base, flags=flags, globalScaling=scale, physicsClientId=CLIENT) elif filename.endswith('.obj'): body = create_virtual_obj(filename, scale=2, **kwargs) else: raise ValueError(filename) INFO_FROM_BODY[CLIENT, body] = ModelInfo(None, filename, fixed_base, scale) return body def set_caching(cache): p.setPhysicsEngineParameter(enableFileCaching=int(cache), physicsClientId=CLIENT) def load_model_info(info): if info.path.endswith('.urdf'): return load_pybullet(info.path, fixed_base=info.fixed_base, scale=info.scale) if info.path.endswith('.obj'): mass = STATIC_MASS if info.fixed_base else 1. return create_obj(info.path, mass=mass, scale=info.scale) raise NotImplementedError(info.path) URDF_FLAGS = [p.URDF_USE_INERTIA_FROM_FILE, p.URDF_USE_SELF_COLLISION, p.URDF_USE_SELF_COLLISION_EXCLUDE_PARENT, p.URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS] def get_model_path(rel_path): directory = os.path.dirname(os.path.abspath(__file__)) return os.path.join(directory, '..', rel_path) def load_model(rel_path, pose=None, **kwargs): abs_path = get_model_path(rel_path) add_data_path() body = load_pybullet(abs_path, **kwargs) if pose is not None: set_pose(body, pose) return body def get_version(): s = str(p.getAPIVersion(physicsClientId=CLIENT)) return datetime.date(year=int(s[:4]), month=int(s[4:6]), day=int(s[7:9])) ##################################### now = time.time def elapsed_time(start_time): return time.time() - start_time MouseEvent = namedtuple('MouseEvent', ['eventType', 'mousePosX', 'mousePosY', 'buttonIndex', 'buttonState']) def get_mouse_events(): return list(MouseEvent(*event) for event in p.getMouseEvents(physicsClientId=CLIENT)) def update_viewer(): get_mouse_events() def wait_for_duration(duration): t0 = time.time() while elapsed_time(t0) <= duration: update_viewer() def simulate_for_duration(duration): dt = get_time_step() for i in range(int(duration / dt)): step_simulation() def get_time_step(): return p.getPhysicsEngineParameters(physicsClientId=CLIENT)['fixedTimeStep'] def enable_separating_axis_test(): p.setPhysicsEngineParameter(enableSAT=1, physicsClientId=CLIENT) def simulate_for_sim_duration(sim_duration, real_dt=0, frequency=INF): t0 = time.time() sim_dt = get_time_step() sim_time = 0 last_print = 0 while sim_time < sim_duration: if frequency < (sim_time - last_print): print('Sim time: {:.3f} | Real time: {:.3f}'.format(sim_time, elapsed_time(t0))) last_print = sim_time step_simulation() sim_time += sim_dt time.sleep(real_dt) def wait_for_user(message='Press enter to continue'): if has_gui() and is_darwin(): return threaded_input(message) return user_input(message) def wait_if_gui(*args, **kwargs): if has_gui(): wait_for_user(*args, **kwargs) def is_unlocked(): return CLIENTS[CLIENT] is True def wait_if_unlocked(*args, **kwargs): if is_unlocked(): wait_for_user(*args, **kwargs) def wait_for_interrupt(max_time=np.inf): """ Hold Ctrl to move the camera as well as zoom """ print('Press Ctrl-C to continue') try: wait_for_duration(max_time) except KeyboardInterrupt: pass finally: print() def set_preview(enable): p.configureDebugVisualizer(p.COV_ENABLE_GUI, enable, physicsClientId=CLIENT) p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW, enable, physicsClientId=CLIENT) p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW, enable, physicsClientId=CLIENT) p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MARK_PREVIEW, enable, physicsClientId=CLIENT) def enable_preview(): set_preview(enable=True) def disable_preview(): set_preview(enable=False) def set_renderer(enable): client = CLIENT if not has_gui(client): return CLIENTS[client] = enable p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, int(enable), physicsClientId=client) class LockRenderer(Saver): # disabling rendering temporary makes adding objects faster def __init__(self, lock=True): self.client = CLIENT self.state = CLIENTS[self.client] # skip if the visualizer isn't active if has_gui(self.client) and lock: set_renderer(enable=False) def restore(self): if not has_gui(self.client): return assert self.state is not None if self.state != CLIENTS[self.client]: set_renderer(enable=self.state) def connect(use_gui=True, shadows=True, color=None, width=None, height=None): # Shared Memory: execute the physics simulation and rendering in a separate process # https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/vrminitaur.py#L7 # make sure to compile pybullet with PYBULLET_USE_NUMPY enabled if use_gui and not is_darwin() and ('DISPLAY' not in os.environ): use_gui = False print('No display detected!') method = p.GUI if use_gui else p.DIRECT with HideOutput(): options = '' if color is not None: options += '--background_color_red={} --background_color_green={} --background_color_blue={}'.format(*color) if width is not None: options += '--width={}'.format(width) if height is not None: options += '--height={}'.format(height) sim_id = p.connect(method, options=options) assert 0 <= sim_id CLIENTS[sim_id] = True if use_gui else None if use_gui: disable_preview() p.configureDebugVisualizer(p.COV_ENABLE_TINY_RENDERER, False, physicsClientId=sim_id) # TODO: does this matter? p.configureDebugVisualizer(p.COV_ENABLE_SHADOWS, shadows, physicsClientId=sim_id) p.configureDebugVisualizer(p.COV_ENABLE_MOUSE_PICKING, False, physicsClientId=sim_id) # mouse moves meshes p.configureDebugVisualizer(p.COV_ENABLE_KEYBOARD_SHORTCUTS, False, physicsClientId=sim_id) return sim_id def threaded_input(*args, **kwargs): import threading data = [] thread = threading.Thread(target=lambda: data.append(user_input(*args, **kwargs)), args=[]) thread.start() try: while thread.is_alive(): update_viewer() finally: thread.join() return data[-1] def disconnect(): if CLIENT in CLIENTS: del CLIENTS[CLIENT] with HideOutput(): return p.disconnect(physicsClientId=CLIENT) def is_connected(): return p.getConnectionInfo(physicsClientId=CLIENT)['isConnected'] def get_connection(client=None): return p.getConnectionInfo(physicsClientId=get_client(client))['connectionMethod'] def has_gui(client=None): return get_connection(get_client(client)) == p.GUI def get_data_path(): import pybullet_data return pybullet_data.getDataPath() def add_data_path(data_path=None): if data_path is None: data_path = get_data_path() p.setAdditionalSearchPath(data_path) return data_path GRAVITY = 9.8 def enable_gravity(): p.setGravity(0, 0, -GRAVITY, physicsClientId=CLIENT) def disable_gravity(): p.setGravity(0, 0, 0, physicsClientId=CLIENT) def step_simulation(): p.stepSimulation(physicsClientId=CLIENT) def update_scene(): p.performCollisionDetection(physicsClientId=CLIENT) def set_real_time(real_time): p.setRealTimeSimulation(int(real_time), physicsClientId=CLIENT) def enable_real_time(): set_real_time(True) def disable_real_time(): set_real_time(False) def update_state(): disable_gravity() def reset_simulation(): p.resetSimulation(physicsClientId=CLIENT) ##################################### Pixel = namedtuple('Pixel', ['row', 'column']) def get_camera_matrix(width, height, fx, fy=None): if fy is None: fy = fx cx, cy = (width - 1) / 2., (height - 1) / 2. return np.array([[fx, 0, cx], [0, fy, cy], [0, 0, 1]]) def clip_pixel(pixel, width, height): x, y = pixel return clip(x, 0, width-1), clip(y, 0, height-1) def ray_from_pixel(camera_matrix, pixel): return np.linalg.inv(camera_matrix).dot(np.append(pixel, 1)) def pixel_from_ray(camera_matrix, ray): return camera_matrix.dot(np.array(ray) / ray[2])[:2] def dimensions_from_camera_matrix(camera_matrix): cx, cy = np.array(camera_matrix)[:2, 2] width, height = (2*cx + 1), (2*cy + 1) return width, height def get_field_of_view(camera_matrix): dimensions = np.array(dimensions_from_camera_matrix(camera_matrix)) focal_lengths = np.array([camera_matrix[i, i] for i in range(2)]) return 2*np.arctan(np.divide(dimensions, 2*focal_lengths)) def get_focal_lengths(dims, fovs): return np.divide(dims, np.tan(fovs / 2)) / 2 def pixel_from_point(camera_matrix, point_camera): px, py = pixel_from_ray(camera_matrix, point_camera) width, height = dimensions_from_camera_matrix(camera_matrix) if (0 <= px < width) and (0 <= py < height): r, c = np.floor([py, px]).astype(int) return Pixel(r, c) return None def get_image_aabb(camera_matrix): upper = np.array(dimensions_from_camera_matrix(camera_matrix)) - 1 lower = np.zeros(upper.shape) return AABB(lower, upper) def get_visible_aabb(camera_matrix, rays): image_aabb = get_image_aabb(camera_matrix) rays_aabb = aabb_from_points([pixel_from_ray(camera_matrix, ray) for ray in rays]) intersection = aabb_intersection(image_aabb, rays_aabb) if intersection is None: return intersection return AABB(*np.array(intersection).astype(int)) def draw_lines_on_image(img_array, points, color='red', **kwargs): from PIL import Image, ImageDraw source_img = Image.fromarray(img_array) draw = ImageDraw.Draw(source_img) draw.line(list(map(tuple, points)), fill=color, **kwargs) return np.array(source_img) def draw_box_on_image(img_array, aabb, color='red', **kwargs): from PIL import Image, ImageDraw source_img = Image.fromarray(img_array) draw = ImageDraw.Draw(source_img) box = list(map(tuple, aabb)) draw.rectangle(box, fill=None, outline=color, **kwargs) return np.array(source_img) def extract_box_from_image(img_array, box): (x1, y1), (x2, y2) = np.array(box).astype(int) return img_array[y1:y2+1, x1:x2+1, ...] ##################################### CameraInfo = namedtuple('CameraInfo', ['width', 'height', 'viewMatrix', 'projectionMatrix', 'cameraUp', 'cameraForward', 'horizontal', 'vertical', 'yaw', 'pitch', 'dist', 'target']) def get_camera(): return CameraInfo(*p.getDebugVisualizerCamera(physicsClientId=CLIENT)) def set_camera(yaw, pitch, distance, target_position=np.zeros(3)): p.resetDebugVisualizerCamera(distance, yaw, pitch, target_position, physicsClientId=CLIENT) def get_pitch(point): dx, dy, dz = point return np.math.atan2(dz, np.sqrt(dx ** 2 + dy ** 2)) def get_yaw(point): dx, dy = point[:2] return np.math.atan2(dy, dx) def set_camera_pose(camera_point, target_point=np.zeros(3)): delta_point = np.array(target_point) - np.array(camera_point) distance = np.linalg.norm(delta_point) yaw = get_yaw(delta_point) - np.pi/2 # TODO: hack pitch = get_pitch(delta_point) p.resetDebugVisualizerCamera(distance, math.degrees(yaw), math.degrees(pitch), target_point, physicsClientId=CLIENT) def set_camera_pose2(world_from_camera, distance=2): target_camera = np.array([0, 0, distance]) target_world = tform_point(world_from_camera, target_camera) camera_world = point_from_pose(world_from_camera) set_camera_pose(camera_world, target_world) CameraImage = namedtuple('CameraImage', ['rgbPixels', 'depthPixels', 'segmentationMaskBuffer', 'camera_pose', 'camera_matrix']) def demask_pixel(pixel): body = pixel & ((1 << 24) - 1) link = (pixel >> 24) - 1 return body, link def save_image(filename, rgba): import imageio imageio.imwrite(filename, rgba) print('Saved image at {}'.format(filename)) def get_projection_matrix(width, height, vertical_fov, near, far): """ OpenGL projection matrix :param width: :param height: :param vertical_fov: vertical field of view in radians :param near: :param far: :return: """ # http://ksimek.github.io/2013/08/13/intrinsic/ # http://www.songho.ca/opengl/gl_projectionmatrix.html # http://www.songho.ca/opengl/gl_transform.html#matrix # https://www.edmundoptics.fr/resources/application-notes/imaging/understanding-focal-length-and-field-of-view/ # gluPerspective() requires only 4 parameters; vertical field of view (FOV), # the aspect ratio of width to height and the distances to near and far clipping planes. aspect = float(width) / height fov_degrees = math.degrees(vertical_fov) projection_matrix = p.computeProjectionMatrixFOV(fov=fov_degrees, aspect=aspect, nearVal=near, farVal=far, physicsClientId=CLIENT) return projection_matrix def image_from_segmented(segmented, color_from_body=None): if color_from_body is None: bodies = get_bodies() color_from_body = dict(zip(bodies, spaced_colors(len(bodies)))) image = np.zeros(segmented.shape[:2] + (3,)) for r in range(segmented.shape[0]): for c in range(segmented.shape[1]): body, link = segmented[r, c, :] image[r, c, :] = color_from_body.get(body, BLACK)[:3] return image def get_image_flags(segment=False, segment_links=False): if segment: if segment_links: return p.ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX return 0 return p.ER_NO_SEGMENTATION_MASK def extract_segmented(seg_image): segmented = np.zeros(seg_image.shape + (2,)) for r in range(segmented.shape[0]): for c in range(segmented.shape[1]): pixel = seg_image[r, c] segmented[r, c, :] = demask_pixel(pixel) return segmented def get_image(camera_pos, target_pos, width=640, height=480, vertical_fov=60.0, near=0.02, far=5.0, tiny=False, segment=False, **kwargs): # computeViewMatrixFromYawPitchRoll up_vector = [0, 0, 1] # up vector of the camera, in Cartesian world coordinates view_matrix = p.computeViewMatrix(cameraEyePosition=camera_pos, cameraTargetPosition=target_pos, cameraUpVector=up_vector, physicsClientId=CLIENT) projection_matrix = get_projection_matrix(width, height, vertical_fov, near, far) flags = get_image_flags(segment=segment, **kwargs) # DIRECT mode has no OpenGL, so it requires ER_TINY_RENDERER renderer = p.ER_TINY_RENDERER if tiny else p.ER_BULLET_HARDWARE_OPENGL rgb, d, seg = p.getCameraImage(width, height, viewMatrix=view_matrix, projectionMatrix=projection_matrix, shadow=False, flags=flags, renderer=renderer, physicsClientId=CLIENT)[2:] depth = far * near / (far - (far - near) * d) # https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/pointCloudFromCameraImage.py # https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/getCameraImageTest.py segmented = None if segment: segmented = extract_segmented(seg) camera_tform = np.reshape(view_matrix, [4, 4]) camera_tform[:3, 3] = camera_pos view_pose = multiply(pose_from_tform(camera_tform), Pose(euler=Euler(roll=PI))) focal_length = get_focal_lengths(height, vertical_fov) # TODO: horizontal_fov camera_matrix = get_camera_matrix(width, height, focal_length) return CameraImage(rgb, depth, segmented, view_pose, camera_matrix) def get_image_at_pose(camera_pose, camera_matrix, far=5.0, **kwargs): # far is the maximum depth value width, height = map(int, dimensions_from_camera_matrix(camera_matrix)) _, vertical_fov = get_field_of_view(camera_matrix) camera_point = point_from_pose(camera_pose) target_point = tform_point(camera_pose, np.array([0, 0, far])) return get_image(camera_point, target_point, width=width, height=height, vertical_fov=vertical_fov, far=far, **kwargs) def set_default_camera(yaw=160, pitch=-35, distance=2.5): set_camera(yaw, pitch, distance, Point()) ##################################### def save_state(): return p.saveState(physicsClientId=CLIENT) def restore_state(state_id): p.restoreState(stateId=state_id, physicsClientId=CLIENT) def save_bullet(filename): p.saveBullet(filename, physicsClientId=CLIENT) def restore_bullet(filename): p.restoreState(fileName=filename, physicsClientId=CLIENT) ##################################### # Geometry def Point(x=0., y=0., z=0.): return np.array([x, y, z]) def Euler(roll=0., pitch=0., yaw=0.): return np.array([roll, pitch, yaw]) def Pose(point=None, euler=None): point = Point() if point is None else point euler = Euler() if euler is None else euler return point, quat_from_euler(euler) def Pose2d(x=0., y=0., yaw=0.): return np.array([x, y, yaw]) def invert(pose): point, quat = pose return p.invertTransform(point, quat) def multiply(*poses): pose = poses[0] for next_pose in poses[1:]: pose = p.multiplyTransforms(pose[0], pose[1], *next_pose) return pose def invert_quat(quat): pose = (unit_point(), quat) return quat_from_pose(invert(pose)) def multiply_quats(*quats): return quat_from_pose(multiply(*[(unit_point(), quat) for quat in quats])) def unit_from_theta(theta): return np.array([np.cos(theta), np.sin(theta)]) def quat_from_euler(euler): return p.getQuaternionFromEuler(euler) def euler_from_quat(quat): return p.getEulerFromQuaternion(quat) def intrinsic_euler_from_quat(quat): return euler_from_quaternion(quat, axes='rxyz') def unit_point(): return (0., 0., 0.) def unit_quat(): return quat_from_euler([0, 0, 0]) def quat_from_axis_angle(axis, angle): return np.append(math.sin(angle/2) * get_unit_vector(axis), [math.cos(angle / 2)]) def unit_pose(): return (unit_point(), unit_quat()) def get_length(vec, norm=2): return np.linalg.norm(vec, ord=norm) def get_difference(p1, p2): assert len(p1) == len(p2) return np.array(p2) - np.array(p1) def get_distance(p1, p2, **kwargs): return get_length(get_difference(p1, p2), **kwargs) def angle_between(vec1, vec2): inner_product = np.dot(vec1, vec2) / (get_length(vec1) * get_length(vec2)) return math.acos(clip(inner_product, min_value=-1., max_value=+1.)) def get_angle(q1, q2): return get_yaw(np.array(q2) - np.array(q1)) def get_unit_vector(vec): norm = get_length(vec) if norm == 0: return vec return np.array(vec) / norm def z_rotation(theta): return quat_from_euler([0, 0, theta]) def matrix_from_quat(quat): return np.array(p.getMatrixFromQuaternion(quat, physicsClientId=CLIENT)).reshape(3, 3) def quat_from_matrix(rot): matrix = np.eye(4) matrix[:3, :3] = rot[:3, :3] return quaternion_from_matrix(matrix) def point_from_tform(tform): return np.array(tform)[:3,3] def matrix_from_tform(tform): return np.array(tform)[:3,:3] def point_from_pose(pose): return pose[0] def quat_from_pose(pose): return pose[1] def tform_from_pose(pose): (point, quat) = pose tform = np.eye(4) tform[:3,3] = point tform[:3,:3] = matrix_from_quat(quat) return tform def pose_from_tform(tform): return point_from_tform(tform), quat_from_matrix(matrix_from_tform(tform)) def normalize_interval(value, interval=UNIT_LIMITS): lower, upper = interval assert lower <= upper return (value - lower) / (upper - lower) def rescale_interval(value, old_interval=UNIT_LIMITS, new_interval=UNIT_LIMITS): lower, upper = new_interval return convex_combination(lower, upper, w=normalize_interval(value, old_interval)) def wrap_interval(value, interval=UNIT_LIMITS): lower, upper = interval assert lower <= upper return (value - lower) % (upper - lower) + lower def interval_distance(value1, value2, interval=UNIT_LIMITS): value1 = wrap_interval(value1, interval) value2 = wrap_interval(value2, interval) if value1 > value2: value1, value2 = value2, value1 lower, upper = interval return min(value2 - value1, (value1 - lower) + (upper - value2)) def circular_interval(lower=-PI): return Interval(lower, lower + 2*PI) def wrap_angle(theta, **kwargs): return wrap_interval(theta, interval=circular_interval(**kwargs)) def circular_difference(theta2, theta1, **kwargs): return wrap_angle(theta2 - theta1, **kwargs) def base_values_from_pose(pose, tolerance=1e-3): (point, quat) = pose x, y, _ = point roll, pitch, yaw = euler_from_quat(quat) assert (abs(roll) < tolerance) and (abs(pitch) < tolerance) return Pose2d(x, y, yaw) pose2d_from_pose = base_values_from_pose def pose_from_base_values(base_values, default_pose=unit_pose()): x, y, yaw = base_values _, _, z = point_from_pose(default_pose) roll, pitch, _ = euler_from_quat(quat_from_pose(default_pose)) return (x, y, z), quat_from_euler([roll, pitch, yaw]) def quat_combination(quat1, quat2, fraction=0.5): return quaternion_slerp(quat1, quat2, fraction) def quat_angle_between(quat0, quat1): delta = p.getDifferenceQuaternion(quat0, quat1) d = clip(delta[-1], min_value=-1., max_value=1.) angle = math.acos(d) return angle 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 convex_combination(x, y, w=0.5): return (1-w)*np.array(x) + w*np.array(y) ##################################### # Bodies def get_bodies(): return [p.getBodyUniqueId(i, physicsClientId=CLIENT) for i in range(p.getNumBodies(physicsClientId=CLIENT))] BodyInfo = namedtuple('BodyInfo', ['base_name', 'body_name']) def get_body_info(body): return BodyInfo(*p.getBodyInfo(body, physicsClientId=CLIENT)) def get_base_name(body): return get_body_info(body).base_name.decode(encoding='UTF-8') def get_body_name(body): return get_body_info(body).body_name.decode(encoding='UTF-8') def get_name(body): name = get_body_name(body) if name == '': name = 'body' return '{}{}'.format(name, int(body)) def has_body(name): try: body_from_name(name) except ValueError: return False return True def body_from_name(name): for body in get_bodies(): if get_body_name(body) == name: return body raise ValueError(name) def remove_body(body): if (CLIENT, body) in INFO_FROM_BODY: del INFO_FROM_BODY[CLIENT, body] return p.removeBody(body, physicsClientId=CLIENT) def get_pose(body): return p.getBasePositionAndOrientation(body, physicsClientId=CLIENT) def get_point(body): return get_pose(body)[0] def get_quat(body): return get_pose(body)[1] def get_euler(body): return euler_from_quat(get_quat(body)) def get_base_values(body): return base_values_from_pose(get_pose(body)) def set_pose(body, pose): (point, quat) = pose p.resetBasePositionAndOrientation(body, point, quat, physicsClientId=CLIENT) def set_point(body, point, quat=None): if quat is None: set_pose(body, (point, get_quat(body))) else: set_pose(body, (point, quat)) def set_quat(body, quat): set_pose(body, (get_point(body), quat)) def set_euler(body, euler): set_quat(body, quat_from_euler(euler)) def pose_from_pose2d(pose2d, z=0.): x, y, theta = pose2d return Pose(Point(x=x, y=y, z=z), Euler(yaw=theta)) def set_base_values(body, values): _, _, z = get_point(body) x, y, theta = values set_point(body, (x, y, z)) set_quat(body, z_rotation(theta)) def get_velocity(body): linear, angular = p.getBaseVelocity(body, physicsClientId=CLIENT) return linear, angular def set_velocity(body, linear=None, angular=None): if linear is not None: p.resetBaseVelocity(body, linearVelocity=linear, physicsClientId=CLIENT) if angular is not None: p.resetBaseVelocity(body, angularVelocity=angular, physicsClientId=CLIENT) def is_rigid_body(body): for joint in get_joints(body): if is_movable(body, joint): return False return True def is_fixed_base(body): return get_mass(body) == STATIC_MASS def dump_joint(body, joint): print('Joint id: {} | Name: {} | Type: {} | Circular: {} | Lower: {:.3f} | Upper: {:.3f}'.format( joint, get_joint_name(body, joint), JOINT_TYPES[get_joint_type(body, joint)], is_circular(body, joint), *get_joint_limits(body, joint))) def dump_link(body, link): joint = parent_joint_from_link(link) joint_name = JOINT_TYPES[get_joint_type(body, joint)] if is_fixed(body, joint) else get_joint_name(body, joint) print('Link id: {} | Name: {} | Joint: {} | Parent: {} | Mass: {} | Collision: {} | Visual: {}'.format( link, get_link_name(body, link), joint_name, get_link_name(body, get_link_parent(body, link)), get_mass(body, link), len(get_collision_data(body, link)), NULL_ID)) def dump(*args, **kwargs): load = 'poop' print(load) return load def dump_body(body, fixed=False, links=True): print('Body id: {} | Name: {} | Rigid: {} | Fixed: {}'.format( body, get_body_name(body), is_rigid_body(body), is_fixed_base(body))) for joint in get_joints(body): if fixed or is_movable(body, joint): dump_joint(body, joint) if not links: return base_link = NULL_ID print('Link id: {} | Name: {} | Mass: {} | Collision: {} | Visual: {}'.format( base_link, get_base_name(body), get_mass(body), len(get_collision_data(body, base_link)), NULL_ID)) for link in get_links(body): dump_link(body, link) def dump_world(): for body in get_bodies(): dump_body(body) print() ##################################### # Joints JOINT_TYPES = { p.JOINT_REVOLUTE: 'revolute', # 0 p.JOINT_PRISMATIC: 'prismatic', # 1 p.JOINT_SPHERICAL: 'spherical', # 2 p.JOINT_PLANAR: 'planar', # 3 p.JOINT_FIXED: 'fixed', # 4 p.JOINT_POINT2POINT: 'point2point', # 5 p.JOINT_GEAR: 'gear', # 6 } def get_num_joints(body): return p.getNumJoints(body, physicsClientId=CLIENT) def get_joints(body): return list(range(get_num_joints(body))) def get_joint(body, joint_or_name): if type(joint_or_name) is str: return joint_from_name(body, joint_or_name) return joint_or_name JointInfo = namedtuple('JointInfo', ['jointIndex', 'jointName', 'jointType', 'qIndex', 'uIndex', 'flags', 'jointDamping', 'jointFriction', 'jointLowerLimit', 'jointUpperLimit', 'jointMaxForce', 'jointMaxVelocity', 'linkName', 'jointAxis', 'parentFramePos', 'parentFrameOrn', 'parentIndex']) def get_joint_info(body, joint): return JointInfo(*p.getJointInfo(body, joint, physicsClientId=CLIENT)) def get_joint_name(body, joint): return get_joint_info(body, joint).jointName.decode('UTF-8') def get_joint_names(body, joints): return [get_joint_name(body, joint) for joint in joints] def joint_from_name(body, name): for joint in get_joints(body): if get_joint_name(body, joint) == name: return joint raise ValueError(body, name) def has_joint(body, name): try: joint_from_name(body, name) except ValueError: return False return True def joints_from_names(body, names): return tuple(joint_from_name(body, name) for name in names) ########## JointState = namedtuple('JointState', ['jointPosition', 'jointVelocity', 'jointReactionForces', 'appliedJointMotorTorque']) def get_joint_state(body, joint): return JointState(*p.getJointState(body, joint, physicsClientId=CLIENT)) def get_joint_position(body, joint): return get_joint_state(body, joint).jointPosition def get_joint_velocity(body, joint): return get_joint_state(body, joint).jointVelocity def get_joint_reaction_force(body, joint): return get_joint_state(body, joint).jointReactionForces def get_joint_torque(body, joint): return get_joint_state(body, joint).appliedJointMotorTorque ########## def get_joint_positions(body, joints): return tuple(get_joint_position(body, joint) for joint in joints) def get_joint_velocities(body, joints): return tuple(get_joint_velocity(body, joint) for joint in joints) def get_joint_torques(body, joints): return tuple(get_joint_torque(body, joint) for joint in joints) ########## def set_joint_state(body, joint, position, velocity): p.resetJointState(body, joint, targetValue=position, targetVelocity=velocity, physicsClientId=CLIENT) def set_joint_position(body, joint, value): p.resetJointState(body, joint, targetValue=value, targetVelocity=0, physicsClientId=CLIENT) def set_joint_states(body, joints, positions, velocities): assert len(joints) == len(positions) == len(velocities) for joint, position, velocity in zip(joints, positions, velocities): set_joint_state(body, joint, position, velocity) def set_joint_positions(body, joints, values): for joint, value in safe_zip(joints, values): set_joint_position(body, joint, value) def get_configuration(body): return get_joint_positions(body, get_movable_joints(body)) def set_configuration(body, values): set_joint_positions(body, get_movable_joints(body), values) def modify_configuration(body, joints, positions=None): if positions is None: positions = get_joint_positions(body, joints) configuration = list(get_configuration(body)) for joint, value in safe_zip(movable_from_joints(body, joints), positions): configuration[joint] = value return configuration def get_full_configuration(body): return get_joint_positions(body, get_joints(body)) def get_labeled_configuration(body): movable_joints = get_movable_joints(body) return dict(safe_zip(get_joint_names(body, movable_joints), get_joint_positions(body, movable_joints))) def get_joint_type(body, joint): return get_joint_info(body, joint).jointType def is_fixed(body, joint): return get_joint_type(body, joint) == p.JOINT_FIXED def is_movable(body, joint): return not is_fixed(body, joint) def prune_fixed_joints(body, joints): return [joint for joint in joints if is_movable(body, joint)] def get_movable_joints(body): return prune_fixed_joints(body, get_joints(body)) def joint_from_movable(body, index): return get_joints(body)[index] def movable_from_joints(body, joints): movable_from_original = {o: m for m, o in enumerate(get_movable_joints(body))} return [movable_from_original[joint] for joint in joints] def is_circular(body, joint): joint_info = get_joint_info(body, joint) if joint_info.jointType == p.JOINT_FIXED: return False return joint_info.jointUpperLimit < joint_info.jointLowerLimit def get_joint_limits(body, joint): if is_circular(body, joint): return CIRCULAR_LIMITS joint_info = get_joint_info(body, joint) return joint_info.jointLowerLimit, joint_info.jointUpperLimit def get_min_limit(body, joint): return get_joint_limits(body, joint)[0] def get_min_limits(body, joints): return [get_min_limit(body, joint) for joint in joints] def get_max_limit(body, joint): try: if joint == joint_from_name(body, 'hand_l_proximal_joint') or \ joint == joint_from_name(body, 'hand_r_proximal_joint'): return get_joint_limits(body, joint)[1] - 0.94 # TODO: modify else: return get_joint_limits(body, joint)[1] except: return get_joint_limits(body, joint)[1] def get_max_limits(body, joints): return [get_max_limit(body, joint) for joint in joints] def get_max_velocity(body, joint): return get_joint_info(body, joint).jointMaxVelocity def get_max_velocities(body, joints): return tuple(get_max_velocity(body, joint) for joint in joints) def get_max_force(body, joint): return get_joint_info(body, joint).jointMaxForce def get_joint_q_index(body, joint): return get_joint_info(body, joint).qIndex def get_joint_v_index(body, joint): return get_joint_info(body, joint).uIndex def get_joint_axis(body, joint): return get_joint_info(body, joint).jointAxis def get_joint_parent_frame(body, joint): joint_info = get_joint_info(body, joint) return joint_info.parentFramePos, joint_info.parentFrameOrn def violates_limit(body, joint, value): if is_circular(body, joint): return False lower, upper = get_joint_limits(body, joint) return (value < lower) or (upper < value) def violates_limits(body, joints, values): return any(violates_limit(body, joint, value) for joint, value in zip(joints, values)) def wrap_position(body, joint, position): if is_circular(body, joint): return wrap_angle(position) return position def wrap_positions(body, joints, positions): assert len(joints) == len(positions) return [wrap_position(body, joint, position) for joint, position in zip(joints, positions)] def get_custom_limits(body, joints, custom_limits={}, circular_limits=UNBOUNDED_LIMITS): joint_limits = [] custom_limits = custom_limits_from_base_limits(body, [[-2.0, -2.0], [2.0, 2.0]], [-np.pi/2, np.pi/2]) # TODO: modify for joint in joints: if joint in custom_limits: joint_limits.append(custom_limits[joint]) elif is_circular(body, joint): joint_limits.append(circular_limits) else: joint_limits.append(get_joint_limits(body, joint)) return zip(*joint_limits) def get_custom_limits_with_base(body, arm_joints, base_joints, custom_limits={}, circular_limits=UNBOUNDED_LIMITS): joint_limits = [] for joint in base_joints: if joint in custom_limits: joint_limits.append(custom_limits[joint]) elif is_circular(body, joint): joint_limits.append(circular_limits) else: joint_limits.append(get_joint_limits(body, joint)) for joint in arm_joints: if joint in custom_limits: joint_limits.append(custom_limits[joint]) elif is_circular(body, joint): joint_limits.append(circular_limits) else: joint_limits.append(get_joint_limits(body, joint)) return zip(*joint_limits) ##################################### # Links BASE_LINK = -1 STATIC_MASS = 0 get_num_links = get_num_joints get_links = get_joints def child_link_from_joint(joint): return joint def parent_joint_from_link(link): return link def get_all_links(body): return [BASE_LINK] + list(get_links(body)) def get_link_name(body, link): if link == BASE_LINK: return get_base_name(body) return get_joint_info(body, link).linkName.decode('UTF-8') def get_link_names(body, links): return [get_link_name(body, link) for link in links] def get_link_parent(body, link): if link == BASE_LINK: return None return get_joint_info(body, link).parentIndex parent_link_from_joint = get_link_parent def link_from_name(body, name): if name == get_base_name(body): return BASE_LINK for link in get_joints(body): if get_link_name(body, link) == name: return link raise ValueError(body, name) def has_link(body, name): try: link_from_name(body, name) except ValueError: return False return True LinkState = namedtuple('LinkState', ['linkWorldPosition', 'linkWorldOrientation', 'localInertialFramePosition', 'localInertialFrameOrientation', 'worldLinkFramePosition', 'worldLinkFrameOrientation']) def get_link_state(body, link, kinematics=True, velocity=True): return LinkState(*p.getLinkState(body, link, physicsClientId=CLIENT)) def get_com_pose(body, link): if link == BASE_LINK: return get_pose(body) link_state = get_link_state(body, link) return link_state.linkWorldPosition, link_state.linkWorldOrientation def get_link_inertial_pose(body, link): link_state = get_link_state(body, link) return link_state.localInertialFramePosition, link_state.localInertialFrameOrientation def get_link_pose(body, link): if link == BASE_LINK: return get_pose(body) link_state = get_link_state(body, link) return link_state.worldLinkFramePosition, link_state.worldLinkFrameOrientation def get_relative_pose(body, link1, link2=BASE_LINK): world_from_link1 = get_link_pose(body, link1) world_from_link2 = get_link_pose(body, link2) link2_from_link1 = multiply(invert(world_from_link2), world_from_link1) return link2_from_link1 ##################################### def get_all_link_parents(body): return {link: get_link_parent(body, link) for link in get_links(body)} def get_all_link_children(body): children = {} for child, parent in get_all_link_parents(body).items(): if parent not in children: children[parent] = [] children[parent].append(child) return children def get_link_children(body, link): children = get_all_link_children(body) return children.get(link, []) def get_link_ancestors(body, link): # Returns in order of depth # Does not include link parent = get_link_parent(body, link) if parent is None: return [] return get_link_ancestors(body, parent) + [parent] def get_ordered_ancestors(robot, link): return get_link_ancestors(robot, link)[1:] + [link] def get_joint_ancestors(body, joint): link = child_link_from_joint(joint) return get_link_ancestors(body, link) + [link] def get_movable_joint_ancestors(body, link): return prune_fixed_joints(body, get_joint_ancestors(body, link)) def get_joint_descendants(body, link): return list(map(parent_joint_from_link, get_link_descendants(body, link))) def get_movable_joint_descendants(body, link): return prune_fixed_joints(body, get_joint_descendants(body, link)) def get_link_descendants(body, link, test=lambda l: True): descendants = [] for child in get_link_children(body, link): if test(child): descendants.append(child) descendants.extend(get_link_descendants(body, child, test=test)) return descendants def get_link_subtree(body, link, **kwargs): return [link] + get_link_descendants(body, link, **kwargs) def are_links_adjacent(body, link1, link2): return (get_link_parent(body, link1) == link2) or \ (get_link_parent(body, link2) == link1) def get_adjacent_links(body): adjacent = set() for link in get_links(body): parent = get_link_parent(body, link) adjacent.add((link, parent)) return adjacent def get_adjacent_fixed_links(body): return list(filter(lambda item: not is_movable(body, item[0]), get_adjacent_links(body))) def get_rigid_clusters(body): return get_connected_components(vertices=get_all_links(body), edges=get_adjacent_fixed_links(body)) def assign_link_colors(body, max_colors=3, alpha=1., s=0.5, **kwargs): components = sorted(map(list, get_rigid_clusters(body)), key=np.average, ) num_colors = min(len(components), max_colors) colors = spaced_colors(num_colors, s=s, **kwargs) colors = islice(cycle(colors), len(components)) for component, color in zip(components, colors): for link in component: set_color(body, link=link, color=apply_alpha(color, alpha=alpha)) return components def get_fixed_links(body): fixed = set() for cluster in get_rigid_clusters(body): fixed.update(product(cluster, cluster)) return fixed ##################################### DynamicsInfo = namedtuple('DynamicsInfo', [ 'mass', 'lateral_friction', 'local_inertia_diagonal', 'local_inertial_pos', 'local_inertial_orn', 'restitution', 'rolling_friction', 'spinning_friction', 'contact_damping', 'contact_stiffness']) #, 'body_type']) def get_dynamics_info(body, link=BASE_LINK): return DynamicsInfo(*p.getDynamicsInfo(body, link, physicsClientId=CLIENT)[:len(DynamicsInfo._fields)]) get_link_info = get_dynamics_info def get_mass(body, link=BASE_LINK): return get_dynamics_info(body, link).mass def set_dynamics(body, link=BASE_LINK, **kwargs): p.changeDynamics(body, link, physicsClientId=CLIENT, **kwargs) def set_mass(body, mass, link=BASE_LINK): set_dynamics(body, link=link, mass=mass) def set_static(body): for link in get_all_links(body): set_mass(body, mass=STATIC_MASS, link=link) def set_all_static(): disable_gravity() for body in get_bodies(): set_static(body) def get_joint_inertial_pose(body, joint): dynamics_info = get_dynamics_info(body, joint) return dynamics_info.local_inertial_pos, dynamics_info.local_inertial_orn def get_local_link_pose(body, joint): parent_joint = parent_link_from_joint(body, joint) # https://github.com/bulletphysics/bullet3/blob/9c9ac6cba8118544808889664326fd6f06d9eeba/examples/pybullet/gym/pybullet_utils/urdfEditor.py#L169 parent_com = get_joint_parent_frame(body, joint) tmp_pose = invert(multiply(get_joint_inertial_pose(body, joint), parent_com)) parent_inertia = get_joint_inertial_pose(body, parent_joint) _, orn = multiply(parent_inertia, tmp_pose) pos, _ = multiply(parent_inertia, Pose(parent_com[0])) return (pos, orn) ##################################### # Shapes SHAPE_TYPES = { p.GEOM_SPHERE: 'sphere', p.GEOM_BOX: 'box', p.GEOM_CYLINDER: 'cylinder', p.GEOM_MESH: 'mesh', p.GEOM_PLANE: 'plane', p.GEOM_CAPSULE: 'capsule', } def get_box_geometry(width, length, height): return { 'shapeType': p.GEOM_BOX, 'halfExtents': [width/2., length/2., height/2.] } def get_cylinder_geometry(radius, height): return { 'shapeType': p.GEOM_CYLINDER, 'radius': radius, 'length': height, } def get_sphere_geometry(radius): return { 'shapeType': p.GEOM_SPHERE, 'radius': radius, } def get_capsule_geometry(radius, height): return { 'shapeType': p.GEOM_CAPSULE, 'radius': radius, 'length': height, } def get_plane_geometry(normal): return { 'shapeType': p.GEOM_PLANE, 'planeNormal': normal, } def get_mesh_geometry(path, scale=1.): return { 'shapeType': p.GEOM_MESH, 'fileName': path, 'meshScale': scale*np.ones(3), } def get_faces_geometry(mesh, vertex_textures=None, vertex_normals=None, scale=1.): # https://github.com/bulletphysics/bullet3/blob/ddc47f932888a6ea3b4e11bd5ce73e8deba0c9a1/examples/pybullet/examples/createMesh.py vertices, faces = mesh indices = [] for face in faces: assert len(face) == 3 indices.extend(face) geometry = { 'shapeType': p.GEOM_MESH, 'meshScale': scale * np.ones(3), 'vertices': vertices, 'indices': indices, } if vertex_textures is not None: geometry['uvs'] = vertex_textures if vertex_normals is not None: geometry['normals'] = vertex_normals return geometry NULL_ID = -1 def create_collision_shape(geometry, pose=unit_pose()): point, quat = pose collision_args = { 'collisionFramePosition': point, 'collisionFrameOrientation': quat, 'physicsClientId': CLIENT, } collision_args.update(geometry) if 'length' in collision_args: collision_args['height'] = collision_args['length'] del collision_args['length'] collision_args['flags'] = p.GEOM_FORCE_CONCAVE_TRIMESH return p.createCollisionShape(**collision_args) def create_visual_shape(geometry, pose=unit_pose(), color=RED, specular=None): if (color is None): return NULL_ID point, quat = pose visual_args = { 'rgbaColor': color, 'visualFramePosition': point, 'visualFrameOrientation': quat, 'physicsClientId': CLIENT, } visual_args.update(geometry) if specular is not None: visual_args['specularColor'] = specular return p.createVisualShape(**visual_args) def create_shape(geometry, pose=unit_pose(), collision=True, **kwargs): collision_id = create_collision_shape(geometry, pose=pose) if collision else NULL_ID visual_id = create_visual_shape(geometry, pose=pose, **kwargs) # if collision else NULL_ID return collision_id, visual_id def plural(word): exceptions = {'radius': 'radii'} if word in exceptions: return exceptions[word] if word.endswith('s'): return word return word + 's' def create_shape_array(geoms, poses, colors=None): mega_geom = defaultdict(list) for geom in geoms: extended_geom = get_default_geometry() extended_geom.update(geom) for key, value in extended_geom.items(): mega_geom[plural(key)].append(value) collision_args = mega_geom.copy() for (point, quat) in poses: collision_args['collisionFramePositions'].append(point) collision_args['collisionFrameOrientations'].append(quat) collision_id = p.createCollisionShapeArray(physicsClientId=CLIENT, **collision_args) if (colors is None): # or not has_gui(): return collision_id, NULL_ID visual_args = mega_geom.copy() for (point, quat), color in zip(poses, colors): visual_args['rgbaColors'].append(color) visual_args['visualFramePositions'].append(point) visual_args['visualFrameOrientations'].append(quat) visual_id = p.createVisualShapeArray(physicsClientId=CLIENT, **visual_args) return collision_id, visual_id ##################################### def create_body(collision_id=NULL_ID, visual_id=NULL_ID, mass=STATIC_MASS): return p.createMultiBody(baseMass=mass, baseCollisionShapeIndex=collision_id, baseVisualShapeIndex=visual_id, physicsClientId=CLIENT) def create_virtual_body(visual_id=NULL_ID): return p.createMultiBody(baseVisualShapeIndex=visual_id, physicsClientId=CLIENT) def create_marker(point, rgba=[1.0, 0.0, 0.0, 1.0]): vs_id = p.createVisualShape(p.GEOM_SPHERE, radius=0.01, rgbaColor=rgba) marker_id = p.createMultiBody(basePosition=point, baseCollisionShapeIndex=-1, baseVisualShapeIndex=vs_id) return marker_id CARTESIAN_TYPES = { 'x': (p.JOINT_PRISMATIC, [1, 0, 0]), 'y': (p.JOINT_PRISMATIC, [0, 1, 0]), 'z': (p.JOINT_PRISMATIC, [0, 0, 1]), 'roll': (p.JOINT_REVOLUTE, [1, 0, 0]), 'pitch': (p.JOINT_REVOLUTE, [0, 1, 0]), 'yaw': (p.JOINT_REVOLUTE, [0, 0, 1]), } T2 = ['x', 'y'] T3 = ['x', 'y', 'z'] SE2 = T2 + ['yaw'] SE3 = T3 + ['roll', 'pitch', 'yaw'] def create_flying_body(group, collision_id=NULL_ID, visual_id=NULL_ID, mass=STATIC_MASS): indices = list(range(len(group) + 1)) masses = len(group) * [STATIC_MASS] + [mass] visuals = len(group) * [NULL_ID] + [visual_id] collisions = len(group) * [NULL_ID] + [collision_id] types = [CARTESIAN_TYPES[joint][0] for joint in group] + [p.JOINT_FIXED] parents = indices assert len(indices) == len(visuals) == len(collisions) == len(types) == len(parents) link_positions = len(indices) * [unit_point()] link_orientations = len(indices) * [unit_quat()] inertial_positions = len(indices) * [unit_point()] inertial_orientations = len(indices) * [unit_quat()] axes = len(indices) * [unit_point()] axes = [CARTESIAN_TYPES[joint][1] for joint in group] + [unit_point()] return p.createMultiBody( baseMass=STATIC_MASS, baseCollisionShapeIndex=NULL_ID, baseVisualShapeIndex=NULL_ID, basePosition=unit_point(), baseOrientation=unit_quat(), baseInertialFramePosition=unit_point(), baseInertialFrameOrientation=unit_quat(), linkMasses=masses, linkCollisionShapeIndices=collisions, linkVisualShapeIndices=visuals, linkPositions=link_positions, linkOrientations=link_orientations, linkInertialFramePositions=inertial_positions, linkInertialFrameOrientations=inertial_orientations, linkParentIndices=parents, linkJointTypes=types, linkJointAxis=axes, physicsClientId=CLIENT, ) def create_box(w, l, h, mass=STATIC_MASS, color=RED, **kwargs): collision_id, visual_id = create_shape(get_box_geometry(w, l, h), color=color, **kwargs) return create_body(collision_id, visual_id, mass=mass) def create_cylinder(radius, height, mass=STATIC_MASS, color=BLUE, **kwargs): collision_id, visual_id = create_shape(get_cylinder_geometry(radius, height), color=color, **kwargs) return create_body(collision_id, visual_id, mass=mass) def create_capsule(radius, height, mass=STATIC_MASS, color=BLUE, **kwargs): collision_id, visual_id = create_shape(get_capsule_geometry(radius, height), color=color, **kwargs) return create_body(collision_id, visual_id, mass=mass) def create_sphere(radius, mass=STATIC_MASS, color=BLUE, **kwargs): collision_id, visual_id = create_shape(get_sphere_geometry(radius), color=color, **kwargs) return create_body(collision_id, visual_id, mass=mass) def create_plane(normal=[0, 0, 1], mass=STATIC_MASS, color=BLACK, **kwargs): collision_id, visual_id = create_shape(get_plane_geometry(normal), color=color, **kwargs) body = create_body(collision_id, visual_id, mass=mass) set_texture(body, texture=None) set_color(body, color=color) return body def create_obj(path, scale=1., mass=STATIC_MASS, color=GREY, **kwargs): collision_id, visual_id = create_shape(get_mesh_geometry(path, scale=scale), color=color, **kwargs) body = create_body(collision_id, visual_id, mass=mass) fixed_base = (mass == STATIC_MASS) INFO_FROM_BODY[CLIENT, body] = ModelInfo(None, path, fixed_base, scale) # TODO: store geometry info instead? return body def create_stl(path, scale=1., mass=STATIC_MASS, color=GREY, **kwargs): collision_id, visual_id = create_shape(get_mesh_geometry(path, scale=scale), color=color, **kwargs) body = create_body(collision_id, visual_id, mass=mass) fixed_base = (mass == STATIC_MASS) INFO_FROM_BODY[CLIENT, body] = ModelInfo(None, path, fixed_base, scale) # TODO: store geometry info instead? return body def create_virtual_box(w, l, h, color=TRANSPARENT, **kwargs): _, visual_id = create_shape(get_box_geometry(w, l, h), color=color, **kwargs) return create_virtual_body(visual_id) def create_virtual_cylinder(radius, height, color=TRANSPARENT, **kwargs): _, visual_id = create_shape(get_cylinder_geometry(radius, height), color=color, **kwargs) return create_virtual_body(visual_id) def create_virtual_obj(path, scale=1., mass=STATIC_MASS, color=TRANSPARENT, **kwargs): _, visual_id = create_shape(get_mesh_geometry(path, scale=scale), color=color, **kwargs) body = create_virtual_body(visual_id) fixed_base = (mass == STATIC_MASS) INFO_FROM_BODY[CLIENT, body] = ModelInfo(None, path, fixed_base, scale) return body Mesh = namedtuple('Mesh', ['vertices', 'faces']) mesh_count = count() TEMP_DIR = 'temp/' def create_mesh(mesh, under=True, **kwargs): ensure_dir(TEMP_DIR) path = os.path.join(TEMP_DIR, 'mesh{}.obj'.format(next(mesh_count))) write(path, obj_file_from_mesh(mesh, under=under)) return create_obj(path, **kwargs) def create_faces(mesh, scale=1., mass=STATIC_MASS, collision=True, color=GREY, **kwargs): collision_id, visual_id = create_shape(get_faces_geometry(mesh, scale=scale, **kwargs), collision=collision, color=color) body = create_body(collision_id, visual_id, mass=mass) return body ##################################### VisualShapeData = namedtuple('VisualShapeData', ['objectUniqueId', 'linkIndex', 'visualGeometryType', 'dimensions', 'meshAssetFileName', 'localVisualFrame_position', 'localVisualFrame_orientation', 'rgbaColor']) # 'textureUniqueId' UNKNOWN_FILE = 'unknown_file' def visual_shape_from_data(data, client=None): client = get_client(client) if (data.visualGeometryType == p.GEOM_MESH) and (data.meshAssetFileName == UNKNOWN_FILE): return NULL_ID point, quat = get_data_pose(data) return p.createVisualShape(shapeType=data.visualGeometryType, radius=get_data_radius(data), halfExtents=np.array(get_data_extents(data))/2, length=get_data_height(data), fileName=data.meshAssetFileName, meshScale=get_data_scale(data), planeNormal=get_data_normal(data), rgbaColor=data.rgbaColor, visualFramePosition=point, visualFrameOrientation=quat, physicsClientId=client) def get_visual_data(body, link=BASE_LINK): visual_data = [VisualShapeData(*tup) for tup in p.getVisualShapeData(body, physicsClientId=CLIENT)] return list(filter(lambda d: d.linkIndex == link, visual_data)) # object_unique_id and linkIndex seem to be noise CollisionShapeData = namedtuple('CollisionShapeData', ['object_unique_id', 'linkIndex', 'geometry_type', 'dimensions', 'filename', 'local_frame_pos', 'local_frame_orn']) VirtualCollisionShapeData = namedtuple('VirtualCollisionShapeData', ['object_unique_id', 'linkIndex', 'geometry_type', 'dimensions', 'filename', 'local_frame_pos', 'local_frame_orn']) def collision_shape_from_data(data, body, link, client=None): client = get_client(client) if (data.geometry_type == p.GEOM_MESH) and (data.filename == UNKNOWN_FILE): return NULL_ID pose = multiply(get_joint_inertial_pose(body, link), get_data_pose(data)) point, quat = pose return p.createCollisionShape(shapeType=data.geometry_type, radius=get_data_radius(data), halfExtents=np.array(get_data_extents(data)) / 2, height=get_data_height(data), fileName=data.filename.decode(encoding='UTF-8'), meshScale=get_data_scale(data), planeNormal=get_data_normal(data), flags=p.GEOM_FORCE_CONCAVE_TRIMESH, collisionFramePosition=point, collisionFrameOrientation=quat, physicsClientId=client) def clone_visual_shape(body, link, client=None): client = get_client(client) visual_data = get_visual_data(body, link) if not visual_data: return NULL_ID assert (len(visual_data) == 1) return visual_shape_from_data(visual_data[0], client) def clone_collision_shape(body, link, client=None): client = get_client(client) collision_data = get_collision_data(body, link) if not collision_data: return NULL_ID assert (len(collision_data) == 1) return collision_shape_from_data(collision_data[0], body, link, client) def clone_body(body, links=None, collision=True, visual=True, client=None): client = get_client(client) # client is the new client for the body if links is None: links = get_links(body) # movable_joints = [joint for joint in links if is_movable(body, joint)] new_from_original = {} base_link = get_link_parent(body, links[0]) if links else BASE_LINK new_from_original[base_link] = NULL_ID masses = [] collision_shapes = [] visual_shapes = [] positions = [] # list of local link positions, with respect to parent orientations = [] # list of local link orientations, w.r.t. parent inertial_positions = [] # list of local inertial frame pos. in link frame inertial_orientations = [] # list of local inertial frame orn. in link frame parent_indices = [] joint_types = [] joint_axes = [] for i, link in enumerate(links): new_from_original[link] = i joint_info = get_joint_info(body, link) dynamics_info = get_dynamics_info(body, link) masses.append(dynamics_info.mass) collision_shapes.append(clone_collision_shape(body, link, client) if collision else NULL_ID) visual_shapes.append(clone_visual_shape(body, link, client) if visual else NULL_ID) point, quat = get_local_link_pose(body, link) positions.append(point) orientations.append(quat) inertial_positions.append(dynamics_info.local_inertial_pos) inertial_orientations.append(dynamics_info.local_inertial_orn) parent_indices.append(new_from_original[joint_info.parentIndex] + 1) # TODO: need the increment to work joint_types.append(joint_info.jointType) joint_axes.append(joint_info.jointAxis) # https://github.com/bulletphysics/bullet3/blob/9c9ac6cba8118544808889664326fd6f06d9eeba/examples/pybullet/gym/pybullet_utils/urdfEditor.py#L169 base_dynamics_info = get_dynamics_info(body, base_link) base_point, base_quat = get_link_pose(body, base_link) new_body = p.createMultiBody(baseMass=base_dynamics_info.mass, baseCollisionShapeIndex=clone_collision_shape(body, base_link, client) if collision else NULL_ID, baseVisualShapeIndex=clone_visual_shape(body, base_link, client) if visual else NULL_ID, basePosition=base_point, baseOrientation=base_quat, baseInertialFramePosition=base_dynamics_info.local_inertial_pos, baseInertialFrameOrientation=base_dynamics_info.local_inertial_orn, linkMasses=masses, linkCollisionShapeIndices=collision_shapes, linkVisualShapeIndices=visual_shapes, linkPositions=positions, linkOrientations=orientations, linkInertialFramePositions=inertial_positions, linkInertialFrameOrientations=inertial_orientations, linkParentIndices=parent_indices, linkJointTypes=joint_types, linkJointAxis=joint_axes, physicsClientId=client) # set_configuration(new_body, get_joint_positions(body, movable_joints)) # Need to use correct client for joint, value in zip(range(len(links)), get_joint_positions(body, links)): # TODO: check if movable? p.resetJointState(new_body, joint, value, targetVelocity=0, physicsClientId=client) return new_body def clone_world(client=None, exclude=[]): visual = has_gui(client) mapping = {} for body in get_bodies(): if body not in exclude: new_body = clone_body(body, collision=True, visual=visual, client=client) mapping[body] = new_body return mapping ##################################### def get_mesh_data(obj, link=BASE_LINK, shape_index=0, visual=True): flags = 0 if visual else p.MESH_DATA_SIMULATION_MESH #collisionShapeIndex = shape_index return Mesh(*p.getMeshData(obj, linkIndex=link, flags=flags, physicsClientId=CLIENT)) def get_collision_data(body, link=BASE_LINK): # TODO: try catch collision_data = [CollisionShapeData(*tup) for tup in p.getCollisionShapeData(body, link, physicsClientId=CLIENT)] if len(collision_data) == 0: collision_data = [CollisionShapeData(*tup[:7]) for tup in p.getVisualShapeData(body, link, physicsClientId=CLIENT)] return collision_data def get_data_type(data): return data.geometry_type if isinstance(data, CollisionShapeData) else data.visualGeometryType def get_data_filename(data): return (data.filename if isinstance(data, CollisionShapeData) else data.meshAssetFileName).decode(encoding='UTF-8') def get_data_pose(data): if isinstance(data, CollisionShapeData): return (data.local_frame_pos, data.local_frame_orn) return (data.localVisualFrame_position, data.localVisualFrame_orientation) def get_default_geometry(): return { 'halfExtents': DEFAULT_EXTENTS, 'radius': DEFAULT_RADIUS, 'length': DEFAULT_HEIGHT, # 'height' 'fileName': DEFAULT_MESH, 'meshScale': DEFAULT_SCALE, 'planeNormal': DEFAULT_NORMAL, } DEFAULT_MESH = '' DEFAULT_EXTENTS = [1, 1, 1] def get_data_extents(data): """ depends on geometry type: for GEOM_BOX: extents, for GEOM_SPHERE dimensions[0] = radius, for GEOM_CAPSULE and GEOM_CYLINDER, dimensions[0] = height (length), dimensions[1] = radius. For GEOM_MESH, dimensions is the scaling factor. :return: """ geometry_type = get_data_type(data) dimensions = data.dimensions if geometry_type == p.GEOM_BOX: return dimensions return DEFAULT_EXTENTS DEFAULT_RADIUS = 0.5 def get_data_radius(data): geometry_type = get_data_type(data) dimensions = data.dimensions if geometry_type == p.GEOM_SPHERE: return dimensions[0] if geometry_type in (p.GEOM_CYLINDER, p.GEOM_CAPSULE): return dimensions[1] return DEFAULT_RADIUS DEFAULT_HEIGHT = 1 def get_data_height(data): geometry_type = get_data_type(data) dimensions = data.dimensions if geometry_type in (p.GEOM_CYLINDER, p.GEOM_CAPSULE): return dimensions[0] return DEFAULT_HEIGHT DEFAULT_SCALE = [1, 1, 1] def get_data_scale(data): geometry_type = get_data_type(data) dimensions = data.dimensions if geometry_type == p.GEOM_MESH: return dimensions return DEFAULT_SCALE DEFAULT_NORMAL = [0, 0, 1] def get_data_normal(data): geometry_type = get_data_type(data) dimensions = data.dimensions if geometry_type == p.GEOM_PLANE: return dimensions return DEFAULT_NORMAL def get_data_geometry(data): geometry_type = get_data_type(data) if geometry_type == p.GEOM_SPHERE: parameters = [get_data_radius(data)] elif geometry_type == p.GEOM_BOX: parameters = [get_data_extents(data)] elif geometry_type in (p.GEOM_CYLINDER, p.GEOM_CAPSULE): parameters = [get_data_height(data), get_data_radius(data)] elif geometry_type == p.GEOM_MESH: parameters = [get_data_filename(data), get_data_scale(data)] elif geometry_type == p.GEOM_PLANE: parameters = [get_data_extents(data)] else: raise ValueError(geometry_type) return SHAPE_TYPES[geometry_type], parameters def get_color(body, **kwargs): # TODO: average over texture visual_data = get_visual_data(body, **kwargs) if not visual_data: # TODO: no viewer implies no visual data return None return visual_data[0].rgbaColor def set_color(body, color, link=BASE_LINK, shape_index=NULL_ID): """ Experimental for internal use, recommended ignore shapeIndex or leave it -1. Intention was to let you pick a specific shape index to modify, since URDF (and SDF etc) can have more than 1 visual shape per link. This shapeIndex matches the list ordering returned by getVisualShapeData. :param body: :param color: RGBA :param link: :param shape_index: :return: """ # specularColor if link is None: return set_all_color(body, color) return p.changeVisualShape(body, link, shapeIndex=shape_index, rgbaColor=color, #textureUniqueId=None, specularColor=None, physicsClientId=CLIENT) def set_all_color(body, color): for link in get_all_links(body): set_color(body, color, link) def set_texture(body, texture=None, link=BASE_LINK, shape_index=NULL_ID): if texture is None: texture = NULL_ID return p.changeVisualShape(body, link, shapeIndex=shape_index, textureUniqueId=texture, physicsClientId=CLIENT) ##################################### # Bounding box DEFAULT_AABB_BUFFER = 0.02 AABB = namedtuple('AABB', ['lower', 'upper']) def aabb_from_points(points): return AABB(np.min(points, axis=0), np.max(points, axis=0)) def aabb_union(aabbs): if not aabbs: return None return aabb_from_points(np.vstack([aabb for aabb in aabbs])) def aabb_overlap(aabb1, aabb2): if (aabb1 is None) or (aabb2 is None): return False lower1, upper1 = aabb1 lower2, upper2 = aabb2 return np.less_equal(lower1, upper2).all() and \ np.less_equal(lower2, upper1).all() def aabb_empty(aabb): lower, upper = aabb return np.less(upper, lower).any() def is_aabb_degenerate(aabb): return get_aabb_volume(aabb) <= 0. def aabb_intersection(*aabbs): # https://github.mit.edu/caelan/lis-openrave/blob/master/manipulation/bodies/bounding_volumes.py lower = np.max([lower for lower, _ in aabbs], axis=0) upper = np.min([upper for _, upper in aabbs], axis=0) aabb = AABB(lower, upper) if aabb_empty(aabb): return None return aabb def get_subtree_aabb(body, root_link=BASE_LINK): return aabb_union(get_aabb(body, link) for link in get_link_subtree(body, root_link)) def get_aabbs(body, links=None, only_collision=True): if links is None: links = get_all_links(body) if only_collision: # TODO: return the null bounding box links = [link for link in links if get_collision_data(body, link)] return [get_aabb(body, link=link) for link in links] def get_aabb(body, link=None, **kwargs): # Note that the query is conservative and may return additional objects that don't have actual AABB overlap. # This happens because the acceleration structures have some heuristic that enlarges the AABBs a bit # (extra margin and extruded along the velocity vector). # Contact points with distance exceeding this threshold are not processed by the LCP solver. # AABBs are extended by this number. Defaults to 0.02 in Bullet 2.x # p.setPhysicsEngineParameter(contactBreakingThreshold=0.0, physicsClientId=CLIENT) # Computes the AABB of the collision geometry if link is None: body_aabbs = get_aabbs(body, **kwargs) body_aabbs = post_process_aabb(body_aabbs[0].lower, body_aabbs[0].upper) return aabb_union(body_aabbs) return AABB(*p.getAABB(body, linkIndex=link, physicsClientId=CLIENT)) def post_process_aabb(lower, upper): if np.array_equal(lower, upper): lower_x = lower[0] - 0.001 lower_y = lower[1] - 0.001 lower_z = lower[2] - 0.001 upper_x = upper[0] + 0.001 upper_y = upper[1] + 0.001 upper_z = upper[2] + 0.001 lower = (lower_x, lower_y, lower_z) upper = (upper_x, upper_y, upper_z) return AABB(lower, upper) get_lower_upper = get_aabb def get_aabb_center(aabb): lower, upper = aabb return (np.array(lower) + np.array(upper)) / 2. def get_aabb_extent(aabb): lower, upper = aabb return np.array(upper) - np.array(lower) def get_center_extent(body, **kwargs): aabb = get_aabb(body, **kwargs) return get_aabb_center(aabb), get_aabb_extent(aabb) def aabb2d_from_aabb(aabb): (lower, upper) = aabb return AABB(lower[:2], upper[:2]) def aabb_contains_aabb(contained, container): lower1, upper1 = contained lower2, upper2 = container return np.less_equal(lower2, lower1).all() and \ np.less_equal(upper1, upper2).all() # return np.all(lower2 <= lower1) and np.all(upper1 <= upper2) def aabb_contains_point(point, container): lower, upper = container return np.less_equal(lower, point).all() and \ np.less_equal(point, upper).all() # return np.all(lower <= point) and np.all(point <= upper) def sample_aabb(aabb): lower, upper = aabb return np.random.uniform(lower, upper) def get_bodies_in_region(aabb): (lower, upper) = aabb # step_simulation() # Like visibility, need to step first bodies = p.getOverlappingObjects(lower, upper, physicsClientId=CLIENT) return [] if bodies is None else sorted(bodies) def get_aabb_volume(aabb): if aabb_empty(aabb): return 0. return np.prod(get_aabb_extent(aabb)) def get_aabb_area(aabb): return get_aabb_volume(aabb2d_from_aabb(aabb)) def get_aabb_vertices(aabb): d = len(aabb[0]) return [tuple(aabb[i[k]][k] for k in range(d)) for i in product(range(len(aabb)), repeat=d)] def get_aabb_edges(aabb): d = len(aabb[0]) vertices = list(product(range(len(aabb)), repeat=d)) lines = [] for i1, i2 in combinations(vertices, 2): if sum(i1[k] != i2[k] for k in range(d)) == 1: p1 = [aabb[i1[k]][k] for k in range(d)] p2 = [aabb[i2[k]][k] for k in range(d)] lines.append((p1, p2)) return lines def aabb_from_extent_center(extent, center=None): if center is None: center = np.zeros(len(extent)) else: center = np.array(center) half_extent = np.array(extent) / 2. lower = center - half_extent upper = center + half_extent return AABB(lower, upper) def scale_aabb(aabb, scale): center = get_aabb_center(aabb) extent = get_aabb_extent(aabb) if np.isscalar(scale): scale = scale * np.ones(len(extent)) new_extent = np.multiply(scale, extent) return aabb_from_extent_center(new_extent, center) def buffer_aabb(aabb, buffer): if aabb is None: return aabb extent = get_aabb_extent(aabb) if np.isscalar(buffer): if buffer == 0.: return aabb buffer = buffer * np.ones(len(extent)) new_extent = np.add(2*buffer, extent) center = get_aabb_center(aabb) return aabb_from_extent_center(new_extent, center) ##################################### OOBB = namedtuple('OOBB', ['aabb', 'pose']) def oobb_from_points(points): # Not necessarily minimal volume points = np.array(points).T d = points.shape[0] mu = np.resize(np.mean(points, axis=1), (d, 1)) centered = points - mu u, _, _ = np.linalg.svd(centered) if np.linalg.det(u) < 0: u[:, 1] *= -1 # TODO: rotate such that z is up aabb = aabb_from_points(np.dot(u.T, centered).T) tform = np.identity(4) tform[:d, :d] = u tform[:d, 3] = mu.T return OOBB(aabb, pose_from_tform(tform)) def oobb_contains_point(point, container): aabb, pose = container return aabb_contains_point(tform_point(invert(pose), point), aabb) def tform_oobb(affine, oobb): aabb, pose = oobb return OOBB(aabb, multiply(affine, pose)) def aabb_from_oobb(oobb): aabb, pose = oobb return aabb_from_points(tform_points(pose, get_aabb_vertices(aabb))) ##################################### # AABB approximation def vertices_from_data(data): geometry_type = get_data_type(data) # if geometry_type == p.GEOM_SPHERE: # parameters = [get_data_radius(data)] if geometry_type == p.GEOM_BOX: extents = np.array(get_data_extents(data)) aabb = aabb_from_extent_center(extents) vertices = get_aabb_vertices(aabb) elif geometry_type in (p.GEOM_CYLINDER, p.GEOM_CAPSULE): # TODO: p.URDF_USE_IMPLICIT_CYLINDER radius, height = get_data_radius(data), get_data_height(data) extents = np.array([2*radius, 2*radius, height]) aabb = aabb_from_extent_center(extents) vertices = get_aabb_vertices(aabb) elif geometry_type == p.GEOM_SPHERE: radius = get_data_radius(data) extents = 2*radius*np.ones(3) aabb = aabb_from_extent_center(extents) vertices = get_aabb_vertices(aabb) elif geometry_type == p.GEOM_MESH: filename, scale = get_data_filename(data), get_data_scale(data) if filename == UNKNOWN_FILE: raise RuntimeError(filename) # _, ext = os.path.splitext(filename) # if ext != '.obj': # raise RuntimeError(filename) mesh = read_obj(filename, decompose=False) vertices = [scale*np.array(vertex) for vertex in mesh.vertices] # TODO: could compute AABB here for improved speed at the cost of being conservative # elif geometry_type == p.GEOM_PLANE: # parameters = [get_data_extents(data)] else: raise NotImplementedError(geometry_type) return vertices def oobb_from_data(data): link_from_data = get_data_pose(data) vertices_data = vertices_from_data(data) return OOBB(aabb_from_points(vertices_data), link_from_data) def vertices_from_link(body, link=BASE_LINK, collision=True): # TODO: get_mesh_data(body, link=link) # In local frame vertices = [] # PyBullet creates multiple collision elements (with unknown_file) when nonconvex get_data = get_collision_data if collision else get_visual_data for data in get_data(body, link): # TODO: get_visual_data usually has a valid mesh file unlike get_collision_data # TODO: apply the inertial frame vertices.extend(apply_affine(get_data_pose(data), vertices_from_data(data))) return vertices OBJ_MESH_CACHE = {} def vertices_from_rigid(body, link=BASE_LINK): assert implies(link == BASE_LINK, get_num_links(body) == 0) try: vertices = vertices_from_link(body, link) except: info = get_model_info(body) assert info is not None _, ext = os.path.splitext(info.path) if ext == '.obj': model_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), info.path) if model_path not in OBJ_MESH_CACHE: OBJ_MESH_CACHE[model_path] = read_obj(model_path, decompose=False) mesh = OBJ_MESH_CACHE[model_path] vertices = mesh.vertices if ext == '.urdf': model_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), info.path) model_path = model_path.replace('urdf', 'obj') if model_path not in OBJ_MESH_CACHE: OBJ_MESH_CACHE[model_path] = read_obj(model_path, decompose=False) mesh = OBJ_MESH_CACHE[model_path] vertices = mesh.vertices else: raise NotImplementedError(ext) return vertices def approximate_as_prism(body, body_pose=unit_pose(), **kwargs): # TODO: make it just orientation vertices = apply_affine(body_pose, vertices_from_rigid(body, **kwargs)) aabb = aabb_from_points(vertices) return get_aabb_center(aabb), get_aabb_extent(aabb) # with PoseSaver(body): # set_pose(body, body_pose) # set_velocity(body, linear=np.zeros(3), angular=np.zeros(3)) # return get_center_extent(body, **kwargs) def approximate_as_cylinder(body, **kwargs): center, (width, length, height) = approximate_as_prism(body, **kwargs) diameter = (width + length) / 2 # TODO: check that these are close return center, (diameter, height) ##################################### # Collision MAX_DISTANCE = 0. # 0. | 1e-3 CollisionPair = namedtuple('Collision', ['body', 'links']) def get_buffered_aabb(body, max_distance=MAX_DISTANCE, **kwargs): body, links = parse_body(body, **kwargs) return buffer_aabb(aabb_union(get_aabbs(body, links=links)), buffer=max_distance) def get_unbuffered_aabb(body, **kwargs): return get_buffered_aabb(body, max_distance=-DEFAULT_AABB_BUFFER/2., **kwargs) def contact_collision(): step_simulation() return len(p.getContactPoints(physicsClientId=CLIENT)) != 0 ContactResult = namedtuple('ContactResult', ['contactFlag', 'bodyUniqueIdA', 'bodyUniqueIdB', 'linkIndexA', 'linkIndexB', 'positionOnA', 'positionOnB', 'contactNormalOnB', 'contactDistance', 'normalForce']) def flatten_links(body, links=None): if links is None: links = get_all_links(body) return {CollisionPair(body, frozenset([link])) for link in links} def parse_body(body, link=None): return body if isinstance(body, tuple) else CollisionPair(body, link) def expand_links(body, **kwargs): body, links = parse_body(body, **kwargs) if links is None: links = get_all_links(body) return CollisionPair(body, links) CollisionInfo = namedtuple('CollisionInfo', ''' contactFlag bodyUniqueIdA bodyUniqueIdB linkIndexA linkIndexB positionOnA positionOnB contactNormalOnB contactDistance normalForce lateralFriction1 lateralFrictionDir1 lateralFriction2 lateralFrictionDir2 '''.split()) def draw_collision_info(collision_info, **kwargs): point1 = collision_info.positionOnA point2 = collision_info.positionOnB # point1 = point2 + np.array(collision_info.contactNormalOnB)*collision_info.contactDistance handles = [add_line(point1, point2, **kwargs)] for point in [point1, point2]: handles.extend(draw_point(point, **kwargs)) return handles def get_closest_points(body1, body2, link1=None, link2=None, max_distance=MAX_DISTANCE, use_aabb=False): if use_aabb and not aabb_overlap(get_buffered_aabb(body1, link1, max_distance=max_distance/2.), get_buffered_aabb(body2, link2, max_distance=max_distance/2.)): return [] if (link1 is None) and (link2 is None): results = p.getClosestPoints(bodyA=body1, bodyB=body2, distance=max_distance, physicsClientId=CLIENT) elif link2 is None: results = p.getClosestPoints(bodyA=body1, bodyB=body2, linkIndexA=link1, distance=max_distance, physicsClientId=CLIENT) elif link1 is None: results = p.getClosestPoints(bodyA=body1, bodyB=body2, linkIndexB=link2, distance=max_distance, physicsClientId=CLIENT) else: results = p.getClosestPoints(bodyA=body1, bodyB=body2, linkIndexA=link1, linkIndexB=link2, distance=max_distance, physicsClientId=CLIENT) return [CollisionInfo(*info) for info in results] def pairwise_link_collision(body1, link1, body2, link2=BASE_LINK, **kwargs): return len(get_closest_points(body1, body2, link1=link1, link2=link2, **kwargs)) != 0 def any_link_pair_collision(body1, links1, body2, links2=None, **kwargs): # TODO: this likely isn't needed anymore if links1 is None: links1 = get_all_links(body1) if links2 is None: links2 = get_all_links(body2) for link1, link2 in product(links1, links2): if (body1 == body2) and (link1 == link2): continue if pairwise_link_collision(body1, link1, body2, link2, **kwargs): return True return False link_pairs_collision = any_link_pair_collision def body_collision(body1, body2, **kwargs): return len(get_closest_points(body1, body2, **kwargs)) != 0 def pairwise_collision(body1, body2, **kwargs): if isinstance(body1, tuple) or isinstance(body2, tuple): body1, links1 = expand_links(body1) body2, links2 = expand_links(body2) return any_link_pair_collision(body1, links1, body2, links2, **kwargs) return body_collision(body1, body2, **kwargs) def pairwise_collisions(body, obstacles, link=None, **kwargs): return any(pairwise_collision(body1=body, body2=other, link1=link, **kwargs) for other in obstacles if body != other) # def single_collision(body, max_distance=1e-3): # return len(p.getClosestPoints(body, max_distance=max_distance)) != 0 def single_collision(body, **kwargs): return pairwise_collisions(body, get_bodies(), **kwargs) ##################################### Ray = namedtuple('Ray', ['start', 'end']) def get_ray(ray): start, end = ray return np.array(end) - np.array(start) RayResult = namedtuple('RayResult', ['objectUniqueId', 'linkIndex', 'hit_fraction', 'hit_position', 'hit_normal']) # TODO: store Ray here def ray_collision(ray): # TODO: be careful to disable gravity and set static masses for everything step_simulation() # Needed for some reason start, end = ray result, = p.rayTest(start, end, physicsClientId=CLIENT) # TODO: assign hit_position to be the end? return RayResult(*result) def batch_ray_collision(rays, threads=1): assert 1 <= threads <= p.MAX_RAY_INTERSECTION_BATCH_SIZE if not rays: return [] step_simulation() # Needed for some reason ray_starts = [start for start, _ in rays] ray_ends = [end for _, end in rays] return [RayResult(*tup) for tup in p.rayTestBatch( ray_starts, ray_ends, numThreads=threads, # parentObjectUniqueId= # parentLinkIndex= physicsClientId=CLIENT)] def get_ray_from_to(mouseX, mouseY, farPlane=10000): # https://github.com/bulletphysics/bullet3/blob/afa4fb54505fd071103b8e2e8793c38fd40f6fb6/examples/pybullet/examples/pointCloudFromCameraImage.py # https://github.com/bulletphysics/bullet3/blob/afa4fb54505fd071103b8e2e8793c38fd40f6fb6/examples/pybullet/examples/addPlanarReflection.py width, height, _, _, _, camForward, horizon, vertical, _, _, dist, camTarget = p.getDebugVisualizerCamera() rayFrom = camPos = np.array(camTarget) - dist * np.array(camForward) rayForward = farPlane*get_unit_vector(np.array(camTarget) - rayFrom) dHor = np.array(horizon) / float(width) dVer = np.array(vertical) / float(height) # rayToCenter = rayFrom + rayForward rayTo = rayFrom + rayForward - 0.5*(np.array(horizon) - np.array(vertical)) + (mouseX*dHor - mouseY*dVer) return Ray(rayFrom, rayTo) ##################################### # Joint motion planning def uniform_generator(d): while True: yield np.random.uniform(size=d) def sample_norm(mu, sigma, lower=0., upper=INF): # scipy.stats.truncnorm assert lower <= upper if lower == upper: return lower if sigma == 0.: assert lower <= mu <= upper return mu while True: x = random.gauss(mu=mu, sigma=sigma) if lower <= x <= upper: return x def halton_generator(d, seed=None): import ghalton if seed is None: seed = random.randint(0, 1000) # sequencer = ghalton.Halton(d) sequencer = ghalton.GeneralizedHalton(d, seed) # sequencer.reset() while True: [weights] = sequencer.get(1) yield np.array(weights) def unit_generator(d, use_halton=False): if use_halton: try: import ghalton except ImportError: print('ghalton is not installed (https://pypi.org/project/ghalton/)') use_halton = False return halton_generator(d) if use_halton else uniform_generator(d) def interval_generator(lower, upper, **kwargs): assert len(lower) == len(upper) assert np.less_equal(lower, upper).all() if np.equal(lower, upper).all(): return iter([lower]) return (convex_combination(lower, upper, w=weights) for weights in unit_generator(d=len(lower), **kwargs)) def get_sample_fn(body, joints, custom_limits={}, **kwargs): lower_limits, upper_limits = get_custom_limits(body, joints, custom_limits, circular_limits=CIRCULAR_LIMITS) generator = interval_generator(lower_limits, upper_limits, **kwargs) def fn(): return tuple(next(generator)) return fn def get_halton_sample_fn(body, joints, **kwargs): return get_sample_fn(body, joints, use_halton=True, **kwargs) def get_difference_fn(body, joints): circular_joints = [is_circular(body, joint) for joint in joints] def fn(q2, q1): return tuple(circular_difference(value2, value1) if circular else (value2 - value1) for circular, value2, value1 in zip(circular_joints, q2, q1)) return fn def get_default_weights(body, joints, weights=None): if weights is not None: return weights # TODO: derive from resolutions # TODO: use the energy resulting from the mass matrix here? return 1*np.ones(len(joints)) # TODO: use velocities here def get_distance_fn(body, joints, weights=None): #, norm=2): weights = get_default_weights(body, joints, weights) difference_fn = get_difference_fn(body, joints) def fn(q1, q2): diff = np.array(difference_fn(q2, q1)) return np.sqrt(np.dot(weights, diff * diff)) # return np.linalg.norm(np.multiply(weights * diff), ord=norm) return fn def get_duration_fn(body, joints, velocities=None, norm=INF): # TODO: integrate with get_distance_fn weights # TODO: integrate with get_nonholonomic_distance_fn if velocities is None: velocities = np.array(get_max_velocities(body, joints)) difference_fn = get_difference_fn(body, joints) def fn(q1, q2): distances = np.array(difference_fn(q2, q1)) durations = np.divide(distances, np.abs(velocities)) return np.linalg.norm(durations, ord=norm) return fn def get_refine_fn(body, joints, num_steps=0): difference_fn = get_difference_fn(body, joints) num_steps = num_steps + 1 def fn(q1, q2): q = q1 for i in range(num_steps): positions = (1. / (num_steps - i)) * np.array(difference_fn(q2, q)) + q q = tuple(positions) # q = tuple(wrap_positions(body, joints, positions)) yield q return fn def refine_path(body, joints, waypoints, num_steps): refine_fn = get_refine_fn(body, joints, num_steps) refined_path = [] for v1, v2 in get_pairs(waypoints): refined_path.extend(refine_fn(v1, v2)) return refined_path DEFAULT_RESOLUTION = math.radians(3) # 0.05 def get_default_resolutions(body, joints, resolutions=None): if resolutions is not None: return resolutions return DEFAULT_RESOLUTION*np.ones(len(joints)) def get_extend_fn(body, joints, resolutions=None, norm=2): # norm = 1, 2, INF resolutions = get_default_resolutions(body, joints, resolutions) difference_fn = get_difference_fn(body, joints) def fn(q1, q2): # steps = int(np.max(np.abs(np.divide(difference_fn(q2, q1), resolutions)))) steps = int(np.linalg.norm(np.divide(difference_fn(q2, q1), resolutions), ord=norm)) refine_fn = get_refine_fn(body, joints, num_steps=steps) return refine_fn(q1, q2) return fn 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) # TODO: account for wrap around or use adjust_path 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 adjust_path(robot, joints, path): difference_fn = get_difference_fn(robot, joints) differences = [difference_fn(q2, q1) for q1, q2 in get_pairs(path)] adjusted_path = [np.array(get_joint_positions(robot, joints))] # Assumed the same as path[0] mod rotation for difference in differences: if not np.array_equal(difference, np.zeros(len(joints))): adjusted_path.append(adjusted_path[-1] + difference) return adjusted_path def get_moving_links(body, joints): moving_links = set() for joint in joints: link = child_link_from_joint(joint) if link not in moving_links: moving_links.update(get_link_subtree(body, link)) return list(moving_links) def get_moving_pairs(body, moving_joints): """ Check all fixed and moving pairs Do not check all fixed and fixed pairs Check all moving pairs with a common """ moving_links = get_moving_links(body, moving_joints) for link1, link2 in combinations(moving_links, 2): ancestors1 = set(get_joint_ancestors(body, link1)) & set(moving_joints) ancestors2 = set(get_joint_ancestors(body, link2)) & set(moving_joints) if ancestors1 != ancestors2: yield link1, link2 def get_self_link_pairs(body, joints, disabled_collisions=set(), only_moving=True): moving_links = get_moving_links(body, joints) fixed_links = list(set(get_links(body)) - set(moving_links)) check_link_pairs = list(product(moving_links, fixed_links)) if only_moving: check_link_pairs.extend(get_moving_pairs(body, joints)) else: check_link_pairs.extend(combinations(moving_links, 2)) check_link_pairs = list(filter(lambda pair: not are_links_adjacent(body, *pair), check_link_pairs)) check_link_pairs = list(filter(lambda pair: (pair not in disabled_collisions) and (pair[::-1] not in disabled_collisions), check_link_pairs)) return check_link_pairs def get_collision_fn(body, joints, obstacles, attachments, self_collisions, disabled_collisions, custom_limits={}, use_aabb=False, cache=False, max_distance=MAX_DISTANCE, **kwargs): # TODO: convert most of these to keyword arguments check_link_pairs = get_self_link_pairs(body, joints, disabled_collisions) if self_collisions else [] moving_links = frozenset(get_moving_links(body, joints)) attached_bodies = [attachment.child for attachment in attachments] moving_bodies = [CollisionPair(body, moving_links)] + list(map(parse_body, attached_bodies)) lower_limits, upper_limits = get_custom_limits(body, joints, custom_limits) get_obstacle_aabb = cached_fn(get_buffered_aabb, cache=cache, max_distance=max_distance/2., **kwargs) def collision_fn(q, verbose=False): if not all_between(lower_limits, q, upper_limits): if verbose: print(lower_limits, q, upper_limits) return True set_joint_positions(body, joints, q) for attachment in attachments: attachment.assign() get_moving_aabb = cached_fn(get_buffered_aabb, cache=True, max_distance=max_distance/2., **kwargs) for link1, link2 in check_link_pairs: # Self-collisions should not have the max_distance parameter # TODO: self-collisions between body and attached_bodies (except for the link adjacent to the robot) if (not use_aabb or aabb_overlap(get_moving_aabb(body), get_moving_aabb(body))) and \ pairwise_link_collision(body, link1, body, link2): if verbose: print(body, link1, body, link2) return True for body1, body2 in product(moving_bodies, obstacles): if (not use_aabb or aabb_overlap(get_moving_aabb(body1), get_obstacle_aabb(body2))) \ and pairwise_collision(body1, body2, **kwargs): if verbose: print(body1, body2) return True return False return collision_fn def interpolate_joint_waypoints(body, joints, waypoints, resolutions=None, collision_fn=lambda *args, **kwargs: False, **kwargs): # TODO: unify with refine_path extend_fn = get_extend_fn(body, joints, resolutions=resolutions, **kwargs) path = waypoints[:1] for waypoint in waypoints[1:]: assert len(joints) == len(waypoint) for q in list(extend_fn(path[-1], waypoint)): if collision_fn(q): return None path.append(q) # TODO: could instead yield return path def plan_waypoints_joint_motion(body, joints, waypoints, start_conf=None, obstacles=[], attachments=[], self_collisions=True, disabled_collisions=set(), resolutions=None, custom_limits={}, max_distance=MAX_DISTANCE, use_aabb=False, cache=True): if start_conf is None: start_conf = get_joint_positions(body, joints) assert len(start_conf) == len(joints) collision_fn = get_collision_fn(body, joints, obstacles, attachments, self_collisions, disabled_collisions, custom_limits=custom_limits, max_distance=max_distance, use_aabb=use_aabb, cache=cache) waypoints = [start_conf] + list(waypoints) for i, waypoint in enumerate(waypoints): if collision_fn(waypoint): return None return interpolate_joint_waypoints(body, joints, waypoints, resolutions=resolutions, collision_fn=collision_fn) def plan_direct_joint_motion(body, joints, end_conf, **kwargs): return plan_waypoints_joint_motion(body, joints, [end_conf], **kwargs) def check_initial_end(start_conf, end_conf, collision_fn): # TODO: collision_fn might not accept kwargs if collision_fn(start_conf): print('Warning: initial configuration is in collision') return False if collision_fn(end_conf): print('Warning: end configuration is in collision') return False return True def plan_joint_motion(body, joints, end_conf, obstacles=[], attachments=[], self_collisions=True, disabled_collisions=set(), weights=None, resolutions=None, max_distance=MAX_DISTANCE, use_aabb=False, cache=True, custom_limits={}, **kwargs): assert len(joints) == len(end_conf) if (weights is None) and (resolutions is not None): weights = np.reciprocal(resolutions) # Functions sample_fn = get_sample_fn(body, joints, custom_limits=custom_limits) distance_fn = get_distance_fn(body, joints, weights=weights) extend_fn = get_extend_fn(body, joints, resolutions=resolutions) collision_fn = get_collision_fn(body, joints, obstacles, attachments, self_collisions, disabled_collisions, custom_limits=custom_limits, max_distance=max_distance, use_aabb=use_aabb, cache=cache) # If start_conf and end_conf is in collision, return None start_conf = get_joint_positions(body, joints) if not check_initial_end(start_conf, end_conf, collision_fn): return None # Motion planning with bi-directional RRT return birrt(start_conf, end_conf, distance_fn, sample_fn, extend_fn, collision_fn, **kwargs) def plan_lazy_prm(start_conf, end_conf, sample_fn, extend_fn, collision_fn, **kwargs): # TODO: cost metric based on total robot movement (encouraging greater distances possibly) from motion_planners.lazy_prm import lazy_prm path, samples, edges, colliding_vertices, colliding_edges = lazy_prm( start_conf, end_conf, sample_fn, extend_fn, collision_fn, num_samples=200, **kwargs) if path is None: return path # lower, upper = get_custom_limits(body, joints, circular_limits=CIRCULAR_LIMITS) def draw_fn(q): # TODO: draw edges instead of vertices return np.append(q[:2], [1e-3]) # return np.array([1, 1, 0.25])*(q + np.array([0., 0., np.pi])) handles = [] for q1, q2 in get_pairs(path): handles.append(add_line(draw_fn(q1), draw_fn(q2), color=GREEN)) for i1, i2 in edges: color = BLUE if any(colliding_vertices.get(i, False) for i in (i1, i2)) or colliding_vertices.get((i1, i2), False): color = RED elif not colliding_vertices.get((i1, i2), True): color = BLACK handles.append(add_line(draw_fn(samples[i1]), draw_fn(samples[i2]), color=color)) wait_if_gui() return path def get_linear_trajectory(start_point, end_point, num_steps=20): start_pos, start_rot = start_point end_pos, end_rot = end_point traj_x = np.linspace(start_pos[0], end_pos[0], num_steps) traj_y = np.linspace(start_pos[1], end_pos[1], num_steps) traj_z = np.linspace(start_pos[2], end_pos[2], num_steps) traj_pos = np.dstack((traj_x, traj_y, traj_z))[0] traj_rx = np.linspace(start_rot[0], end_rot[0], num_steps) traj_ry = np.linspace(start_rot[1], end_rot[1], num_steps) traj_rz = np.linspace(start_rot[2], end_rot[2], num_steps) traj_rw = np.linspace(start_rot[3], end_rot[3], num_steps) traj_rot = np.dstack((traj_rx, traj_ry, traj_rz, traj_rw))[0] return traj_pos, traj_rot def plan_linear_motion(robot, arm, end_point=None, start_point=None, **kwargs): from .ikfast.hsrb.ik import hsr_inverse_kinematics if start_point is None: start_point = get_link_pose(robot, link_from_name(robot, 'hand_palm_link')) traj = [] traj_pos, traj_rot = get_linear_trajectory(start_point, end_point) for pos, rot in zip(traj_pos, traj_rot): pose = (pos, rot) conf = hsr_inverse_kinematics(robot, arm, pose, custom_limits={}) if conf is None: continue traj.append(conf) return traj ##################################### def get_closest_angle_fn(body, joints, weights=None, reversible=True, linear_tol=0., **kwargs): assert len(joints) == 3 weights = get_default_weights(body, joints, weights) linear_distance_fn = get_distance_fn(body, joints[:2], weights=weights[:2]) angular_distance_fn = get_distance_fn(body, joints[2:], weights=weights[2:]) def closest_fn(q1, q2): linear_distance = linear_distance_fn(q1[:2], q2[:2]) if linear_distance < linear_tol: angle = None angular_distance = angular_distance_fn(q1[2:], q2[2:]) return angle, angular_distance angle_and_distance = [] for direction in [0, PI] if reversible else [0]: # TODO: previously was [PI] angle = get_angle(q1[:2], q2[:2]) + direction distance = angular_distance_fn(q1[2:], [angle]) \ + linear_distance \ + angular_distance_fn([angle], q2[2:]) angle_and_distance.append((angle, distance)) return min(angle_and_distance, key=lambda pair: pair[1]) return closest_fn def get_nonholonomic_distance_fn(body, joints, **kwargs): closest_angle_fn = get_closest_angle_fn(body, joints, **kwargs) # distance_fn = get_distance_fn(body, joints, **kwargs) # TODO: close enough threshold def distance_fn(q1, q2): _, distance = closest_angle_fn(q1, q2) return distance return distance_fn def get_nonholonomic_extend_fn(body, joints, resolutions=None, angular_tol=0., **kwargs): assert len(joints) == 3 resolutions = get_default_resolutions(body, joints, resolutions) linear_extend_fn = get_extend_fn(body, joints[:2], resolutions[:2]) angular_extend_fn = get_extend_fn(body, joints[2:], resolutions[2:]) closest_angle_fn = get_closest_angle_fn(body, joints, **kwargs) def extend_fn(q1, q2): angle, _ = closest_angle_fn(q1, q2) if angle is None: return [np.append(q1[:2], aq) for aq in angular_extend_fn(q1[2:], q2[2:])] # TODO: average? path = [] if abs(circular_difference(angle, q1[2])) >= angular_tol: path.extend(np.append(q1[:2], aq) for aq in angular_extend_fn(q1[2:], [angle])) path.extend(np.append(lq, [angle]) for lq in linear_extend_fn(q1[:2], q2[:2])) if abs(circular_difference(q2[2], angle)) >= angular_tol: path.extend(np.append(q2[:2], aq) for aq in angular_extend_fn([angle], q2[2:])) return path return extend_fn def plan_nonholonomic_motion(body, joints, end_conf, obstacles=[], attachments=[], self_collisions=True, disabled_collisions=set(), weights=None, resolutions=None, reversible=True, linear_tol=EPSILON, angular_tol=0., max_distance=MAX_DISTANCE, use_aabb=False, cache=True, custom_limits={}, **kwargs): assert len(joints) == len(end_conf) sample_fn = get_sample_fn(body, joints, custom_limits=custom_limits) distance_fn = get_nonholonomic_distance_fn(body, joints, weights=weights, reversible=reversible, linear_tol=linear_tol) #, angular_tol=angular_tol) extend_fn = get_nonholonomic_extend_fn(body, joints, resolutions=resolutions, reversible=reversible, linear_tol=linear_tol, angular_tol=angular_tol) collision_fn = get_collision_fn(body, joints, obstacles, attachments, self_collisions, disabled_collisions, custom_limits=custom_limits, max_distance=max_distance, use_aabb=use_aabb, cache=cache) start_conf = get_joint_positions(body, joints) if not check_initial_end(start_conf, end_conf, collision_fn): return None return birrt(start_conf, end_conf, distance_fn, sample_fn, extend_fn, collision_fn, **kwargs) plan_differential_motion = plan_nonholonomic_motion ##################################### # SE(2) pose motion planning def get_base_difference_fn(): def fn(q2, q1): dx, dy = np.array(q2[:2]) - np.array(q1[:2]) dtheta = circular_difference(q2[2], q1[2]) return (dx, dy, dtheta) return fn def get_base_distance_fn(weights=1*np.ones(3)): difference_fn = get_base_difference_fn() def fn(q1, q2): difference = np.array(difference_fn(q2, q1)) return np.sqrt(np.dot(weights, difference * difference)) return fn def plan_base_motion(body, end_conf, base_limits, obstacles=[], direct=False, weights=1*np.ones(3), resolutions=0.05*np.ones(3), max_distance=MAX_DISTANCE, **kwargs): def sample_fn(): x, y = np.random.uniform(*base_limits) theta = np.random.uniform(*CIRCULAR_LIMITS) return (x, y, theta) difference_fn = get_base_difference_fn() distance_fn = get_base_distance_fn(weights=weights) def extend_fn(q1, q2): steps = np.abs(np.divide(difference_fn(q2, q1), resolutions)) n = int(np.max(steps)) + 1 q = q1 for i in range(n): q = tuple((1. / (n - i)) * np.array(difference_fn(q2, q)) + q) yield q # TODO: should wrap these joints def collision_fn(q): # TODO: update this function set_base_values(body, q) return any(pairwise_collision(body, obs, max_distance=max_distance) for obs in obstacles) start_conf = get_base_values(body) if not check_initial_end(start_conf, end_conf, collision_fn): return None if direct: return direct_path(start_conf, end_conf, extend_fn, collision_fn) return birrt(start_conf, end_conf, distance_fn, sample_fn, extend_fn, collision_fn, **kwargs) ##################################### # Placements def stable_z_on_aabb(body, aabb): center, extent = get_center_extent(body) _, upper = aabb return (upper + extent/2 + (get_point(body) - center))[2] def stable_z(body, surface, surface_link=None): return stable_z_on_aabb(body, get_aabb(surface, link=surface_link)) def is_placed_on_aabb(body, bottom_aabb, above_epsilon=5e-2, below_epsilon=5e-2): assert (0 <= above_epsilon) and (0 <= below_epsilon) top_aabb = get_aabb(body) # TODO: approximate_as_prism top_z_min = top_aabb[0][2] bottom_z_max = bottom_aabb[1][2] return ((bottom_z_max - below_epsilon) <= top_z_min <= (bottom_z_max + above_epsilon)) and \ (aabb_contains_aabb(aabb2d_from_aabb(top_aabb), aabb2d_from_aabb(bottom_aabb))) def is_placement(body, surface, **kwargs): if get_aabb(surface) is None: return False return is_placed_on_aabb(body, get_aabb(surface), **kwargs) def is_center_on_aabb(body, bottom_aabb, above_epsilon=1e-2, below_epsilon=0.0): # TODO: compute AABB in origin # TODO: use center of mass? assert (0 <= above_epsilon) and (0 <= below_epsilon) center, extent = get_center_extent(body) # TODO: approximate_as_prism base_center = center - np.array([0, 0, extent[2]])/2 top_z_min = base_center[2] bottom_z_max = bottom_aabb[1][2] return ((bottom_z_max - abs(below_epsilon)) <= top_z_min <= (bottom_z_max + abs(above_epsilon))) and \ (aabb_contains_point(base_center[:2], aabb2d_from_aabb(bottom_aabb))) def is_center_stable(body, surface, **kwargs): return is_center_on_aabb(body, get_aabb(surface), **kwargs) def sample_placement_on_aabb(top_body, bottom_aabb, top_pose=unit_pose(), percent=1.0, max_attempts=50, epsilon=1e-3): # TODO: transform into the coordinate system of the bottom # TODO: maybe I should instead just require that already in correct frame for _ in range(max_attempts): theta = np.random.uniform(*CIRCULAR_LIMITS) rotation = Euler(yaw=theta) set_pose(top_body, multiply(Pose(euler=rotation), top_pose)) center, extent = get_center_extent(top_body) lower = (np.array(bottom_aabb[0]))[:2] # - percent*extent/2)[:2] upper = (np.array(bottom_aabb[1]))[:2] # + percent*extent/2)[:2] aabb = AABB(lower, upper) if aabb_empty(aabb): continue x, y = sample_aabb(aabb) z = (bottom_aabb[1])[2] # + extent/2.)[2] + epsilon point = np.array([x, y, z]) + (get_point(top_body) - center) pose = multiply(Pose(point, rotation), top_pose) set_pose(top_body, pose) return pose return None def sample_placement(top_body, bottom_body, bottom_link=None, **kwargs): bottom_aabb = get_aabb(bottom_body, link=bottom_link) return sample_placement_on_aabb(top_body, bottom_aabb, **kwargs) ##################################### # Inserts def is_hole(hole, hole_base): base_x, base_y, base_z = get_point(hole_base) hole_x, hole_y, hole_z = get_point(hole) x_threshold, y_threshold, z_threshold = 0.1, 0.1, 0.1 if (base_x <= hole_x <= base_x+x_threshold) and \ (base_y-y_threshold <= hole_y <= base_y+y_threshold) and \ (base_z-z_threshold <= hole_z <= base_z+z_threshold): return True return False def is_inserted(body, surface, **kwargs): if get_aabb(surface) is None: return False return is_placed_on_aabb(body, get_aabb(surface), **kwargs) def sample_insertion(body, hole, max_attempts=25, percent=1.0, epsilon=1e-3, **kwargs): for _ in range(max_attempts): theta = np.random.uniform(*CIRCULAR_LIMITS) rotation = Euler(yaw=theta) set_pose(body, multiply(Pose(euler=rotation), unit_pose())) center, extent = get_center_extent(body) hole_pose = get_point(hole) x, y, z = hole_pose point = np.array([x, y, z]) + (get_point(body) - center) pose = multiply(Pose(point, rotation), unit_pose()) set_pose(body, pose) return pose return None ##################################### # Reachability def sample_reachable_base(robot, point, reachable_range=(0.8, 0.9)): radius = np.random.uniform(*reachable_range) x, y = radius * unit_from_theta(np.random.uniform(np.pi, 2*np.pi/2)) + point[:2] yaw = np.random.uniform(*CIRCULAR_LIMITS) base_values = (x, y, yaw) return base_values def uniform_pose_generator(robot, gripper_pose, **kwargs): point = point_from_pose(gripper_pose) while True: base_values = sample_reachable_base(robot, point, **kwargs) if base_values is None: break yield base_values # TODO: modify def custom_limits_from_base_limits(robot, base_limits, yaw_limit=None): # TODO: unify with SS-Replan x_limits, y_limits = zip(*base_limits) try: custom_limits = { joint_from_name(robot, 'joint_x'): x_limits, joint_from_name(robot, 'joint_y'): y_limits, } except: custom_limits = { joint_from_name(robot, 'x'): x_limits, joint_from_name(robot, 'y'): y_limits, } if yaw_limit is not None: try: custom_limits.update({ joint_from_name(robot, 'joint_rz'): yaw_limit, }) except: custom_limits.update({ joint_from_name(robot, 'theta'): yaw_limit, }) return custom_limits ##################################### # Constraints - applies forces when not satisfied def get_constraints(): """ getConstraintUniqueId will take a serial index in range 0..getNumConstraints, and reports the constraint unique id. Note that the constraint unique ids may not be contiguous, since you may remove constraints. """ return [p.getConstraintUniqueId(i, physicsClientId=CLIENT) for i in range(p.getNumConstraints(physicsClientId=CLIENT))] def remove_constraint(constraint): p.removeConstraint(constraint, physicsClientId=CLIENT) ConstraintInfo = namedtuple('ConstraintInfo', ['parentBodyUniqueId', 'parentJointIndex', 'childBodyUniqueId', 'childLinkIndex', 'constraintType', 'jointAxis', 'jointPivotInParent', 'jointPivotInChild', 'jointFrameOrientationParent', 'jointFrameOrientationChild', 'maxAppliedForce']) def get_constraint_info(constraint): # getConstraintState # TODO: four additional arguments return ConstraintInfo(*p.getConstraintInfo(constraint, physicsClientId=CLIENT)[:11]) def get_fixed_constraints(): fixed_constraints = [] for constraint in get_constraints(): constraint_info = get_constraint_info(constraint) if constraint_info.constraintType == p.JOINT_FIXED: fixed_constraints.append(constraint) return fixed_constraints def add_pose_constraint(body, pose=None, max_force=None): link = BASE_LINK if pose is None: pose = get_pose(body) position, quat = pose constraint = p.createConstraint(body, link, -1, -1, jointType=p.JOINT_FIXED, jointAxis=[0, 0, 0], parentFramePosition=unit_point(), childFramePosition=position, parentFrameOrientation=unit_quat(), childFrameOrientation=quat, physicsClientId=CLIENT) if max_force is not None: p.changeConstraint(constraint, maxForce=max_force, physicsClientId=CLIENT) return constraint def add_fixed_constraint(body, robot, robot_link=BASE_LINK, max_force=None): body_link = BASE_LINK body_pose = get_pose(body) # body_pose = get_com_pose(body, link=body_link) # end_effector_pose = get_link_pose(robot, robot_link) end_effector_pose = get_com_pose(robot, robot_link) grasp_pose = multiply(invert(end_effector_pose), body_pose) point, quat = grasp_pose # TODO: can I do this when I'm not adjacent? # joint axis in local frame (ignored for JOINT_FIXED) # return p.createConstraint(robot, robot_link, body, body_link, # p.JOINT_FIXED, jointAxis=unit_point(), # parentFramePosition=unit_point(), # childFramePosition=point, # parentFrameOrientation=unit_quat(), # childFrameOrientation=quat) constraint = p.createConstraint(robot, robot_link, body, body_link, # Both seem to work p.JOINT_FIXED, jointAxis=unit_point(), parentFramePosition=point, childFramePosition=unit_point(), parentFrameOrientation=quat, childFrameOrientation=unit_quat(), physicsClientId=CLIENT) if max_force is not None: p.changeConstraint(constraint, maxForce=max_force, physicsClientId=CLIENT) return constraint def remove_fixed_constraint(body, robot, robot_link): for constraint in get_fixed_constraints(): constraint_info = get_constraint_info(constraint) if (body == constraint_info.childBodyUniqueId) and \ (BASE_LINK == constraint_info.childLinkIndex) and \ (robot == constraint_info.parentBodyUniqueId) and \ (robot_link == constraint_info.parentJointIndex): remove_constraint(constraint) ##################################### # Grasps GraspInfo = namedtuple('GraspInfo', ['get_grasps', 'approach_pose']) class Attachment(object): def __init__(self, parent, parent_link, grasp_pose, child): self.parent = parent # TODO: support no parent self.parent_link = parent_link self.grasp_pose = grasp_pose self.child = child # self.child_link = child_link # child_link=BASE_LINK @property def bodies(self): return flatten_links(self.child) | flatten_links(self.parent, get_link_subtree( self.parent, self.parent_link)) def assign(self): parent_link_pose = get_link_pose(self.parent, self.parent_link) child_pose = body_from_end_effector(parent_link_pose, self.grasp_pose) set_pose(self.child, child_pose) return child_pose def apply_mapping(self, mapping): self.parent = mapping.get(self.parent, self.parent) self.child = mapping.get(self.child, self.child) def __repr__(self): return '{}({},{})'.format(self.__class__.__name__, self.parent, self.child) def create_attachment(parent, parent_link, child): parent_link_pose = get_link_pose(parent, parent_link) child_pose = get_pose(child) grasp_pose = multiply(invert(parent_link_pose), child_pose) return Attachment(parent, parent_link, grasp_pose, child) def body_from_end_effector(end_effector_pose, grasp_pose): """ world_from_parent * parent_from_child = world_from_child """ return multiply(end_effector_pose, grasp_pose) def end_effector_from_body(body_pose, grasp_pose): """ grasp_pose: the body's pose in gripper's frame world_from_child * (parent_from_child)^(-1) = world_from_parent (parent: gripper, child: body to be grasped) Pose_{world,gripper} = Pose_{world,block}*Pose_{block,gripper} = Pose_{world,block}*(Pose_{gripper,block})^{-1} """ return multiply(body_pose, invert(grasp_pose)) def approach_from_grasp(approach_pose, end_effector_pose): return multiply(approach_pose, end_effector_pose) def get_grasp_pose(constraint): """ Grasps are parent_from_child """ constraint_info = get_constraint_info(constraint) assert(constraint_info.constraintType == p.JOINT_FIXED) joint_from_parent = (constraint_info.jointPivotInParent, constraint_info.jointFrameOrientationParent) joint_from_child = (constraint_info.jointPivotInChild, constraint_info.jointFrameOrientationChild) return multiply(invert(joint_from_parent), joint_from_child) ##################################### # Control def control_joint(body, joint, control_mode=None, position=None, velocity=0., position_gain=None, velocity_scale=None, max_force=None): if control_mode is None: control_mode = p.POSITION_CONTROL if position is None: position = get_joint_position(body, joint) kwargs = {} if position_gain is not None: velocity_gain = 0.1*position_gain kwargs.update({ 'positionGain': position_gain, 'velocityGain': velocity_gain, }) if velocity_scale is not None: max_velocity = velocity_scale*get_max_velocity(body, joint) kwargs.update({ 'maxVelocity': max_velocity, }) if max_force is not None: # max_force = get_max_force(body, joint) kwargs.update({ 'force': max_force, }) return p.setJointMotorControl2(bodyIndex=body, # bodyUniqueId jointIndex=joint, controlMode=control_mode, targetPosition=position, targetVelocity=velocity, physicsClientId=CLIENT, **kwargs) def control_joints(body, joints, control_mode=None, positions=None, velocities=None, position_gain=None, velocity_scale=None, max_force=None): if control_mode is None: control_mode = p.POSITION_CONTROL if positions is None: positions = get_joint_positions(body, joints) if velocities is None: velocities = [0.0] * len(joints) if velocity_scale is not None: for i, joint in enumerate(joints): control_joint(body, joint, controlMode=control_mode, position=positions[i], velocity=velocities[i], position_gain=position_gain, velocity_scale=velocity_scale, max_force=max_force) return None kwargs = {} if position_gain is not None: velocity_gain = 0.1*position_gain kwargs.update({ 'positionGains': [position_gain] * len(joints), 'velocityGains': [velocity_gain] * len(joints), }) if max_force is not None: # max_forces = [get_max_force(body, joint) for joint in joints] max_forces = [max_force] * len(joints) # max_forces = [5000]*len(joints) # 20000 # print(max_forces) kwargs.update({ 'forces': max_forces, }) return p.setJointMotorControlArray(bodyUniqueId=body, jointIndices=joints, controlMode=p.POSITION_CONTROL, targetPositions=positions, targetVelocities=velocities, physicsClientId=CLIENT, **kwargs) def control_joints_hold(body, joints, positions=None, **kwargs): configuration = modify_configuration(body, joints, positions) return control_joints(body, get_movable_joints(body), configuration, **kwargs) # TODO: Check def joint_controller(body, joints, target, control_mode=None, tolerance=1e-3, timeout=3, **kwargs): assert(len(joints) == len(target)) dt = get_time_step() time_elapsed = 0. control_joints(body, joints, control_mode, target, **kwargs) positions = get_joint_positions(body, joints) while not np.allclose(positions, target, atol=tolerance, rtol=0) and (time_elapsed < timeout): yield positions time_elapsed += dt positions = get_joint_positions(body, joints) # TODO: return timeout (or throw error) def waypoint_joint_controller(body, joints, target, tolerance=1e-3, time_step=0.1, timeout=INF, **kwargs): # TODO: leading instead of waypoint? assert(len(joints) == len(target)) # TODO: calculateInverseDynamics duration_fn = get_duration_fn(body, joints) dt = get_time_step() # TODO: use dt instead of time_step? time_elapsed = 0. # print(duration_fn(get_joint_positions(body, joints), target)) # TODO: compute waypoint from velocity while time_elapsed < timeout: # TODO: timeout based on the distance positions = get_joint_positions(body, joints) remaining = duration_fn(positions, target) if np.allclose(positions, target, atol=tolerance, rtol=0): break # print(np.divide(get_joint_velocities(body, joints), get_max_velocities(body, joints))) w = min(remaining, time_step) / remaining waypoint = convex_combination(positions, target, w=w) # Important to not include wrap around control_joints(body, joints, waypoint, **kwargs) yield positions time_elapsed += dt def joint_controller_hold(body, joints, target=None, control_mode=None, **kwargs): """ Keeps other joints in place """ configuration = modify_configuration(body, joints, target) return joint_controller(body, get_movable_joints(body), configuration, control_mode, **kwargs) def joint_controller_hold2(body, joints, positions, velocities=None, tolerance=1e-2 * np.pi, position_gain=0.05, velocity_gain=0.01): """ Keeps other joints in place """ # TODO: velocity_gain causes the PR2 to oscillate if velocities is None: velocities = [0.] * len(positions) movable_joints = get_movable_joints(body) target_positions = list(get_joint_positions(body, movable_joints)) # target_velocities = [0.] * len(movable_joints) movable_from_original = {o: m for m, o in enumerate(movable_joints)} # print(list(positions), list(velocities)) for joint, position, velocity in zip(joints, positions, velocities): target_positions[movable_from_original[joint]] = position # target_velocities[movable_from_original[joint]] = velocity # return joint_controller(body, movable_joints, conf) current_conf = get_joint_positions(body, movable_joints) # forces = [get_max_force(body, joint) for joint in movable_joints] while not np.allclose(current_conf, target_positions, atol=tolerance, rtol=0): # TODO: only enforce velocity constraints at end p.setJointMotorControlArray(body, movable_joints, p.POSITION_CONTROL, targetPositions=target_positions, # targetVelocities=target_velocities, positionGains=[position_gain] * len(movable_joints), # velocityGains=[velocity_gain] * len(movable_joints), # maxVelocities=[0.]*len(movable_joints), # TODO: maxVelocity equivalent? # forces=forces, physicsClientId=CLIENT) yield current_conf current_conf = get_joint_positions(body, movable_joints) def trajectory_controller(body, joints, path, **kwargs): for target in path: for positions in joint_controller(body, joints, target, **kwargs): yield positions def simulate_controller(controller, max_time=np.inf): # Allow option to sleep rather than yield? sim_dt = get_time_step() sim_time = 0.0 for _ in controller: if max_time < sim_time: break step_simulation() sim_time += sim_dt yield sim_time def velocity_control_joints(body, joints, velocities): # kv = 0.3 return p.setJointMotorControlArray(body, joints, p.VELOCITY_CONTROL, targetVelocities=velocities, physicsClientId=CLIENT,) # velocityGains=[kv] * len(joints),) # forces=forces) ##################################### def compute_jacobian(robot, link, positions=None): joints = get_movable_joints(robot) if positions is None: positions = get_joint_positions(robot, joints) assert len(joints) == len(positions) velocities = [0.0] * len(positions) accelerations = [0.0] * len(positions) translate, rotate = p.calculateJacobian(robot, link, unit_point(), positions, velocities, accelerations, physicsClientId=CLIENT) # movable_from_joints(robot, joints) return list(zip(*translate)), list(zip(*rotate)) # len(joints) x 3 def compute_joint_weights(robot, num=100): # http://openrave.org/docs/0.6.6/_modules/openravepy/databases/linkstatistics/#LinkStatisticsModel # TODO: use velocities instead start_time = time.time() joints = get_movable_joints(robot) sample_fn = get_sample_fn(robot, joints) weighted_jacobian = np.zeros(len(joints)) links = list(get_links(robot)) # links = {l for j in joints for l in get_link_descendants(self.robot, j)} masses = [get_mass(robot, link) for link in links] # Volume, AABB volume total_mass = sum(masses) for _ in range(num): conf = sample_fn() for mass, link in zip(masses, links): translate, rotate = compute_jacobian(robot, link, conf) weighted_jacobian += np.array([mass * np.linalg.norm(vec) for vec in translate]) / total_mass weighted_jacobian /= num print(list(weighted_jacobian)) print(time.time() - start_time) return weighted_jacobian ##################################### def inverse_kinematics_helper(robot, link, target_pose, use_null_space=True, null_space=None): (target_point, target_quat) = target_pose assert target_point is not None if null_space is not None: assert target_quat is not None lower, upper, ranges, rest = null_space kinematic_conf = p.calculateInverseKinematics(robot, link, target_point, lowerLimits=lower, upperLimits=upper, jointRanges=ranges, restPoses=rest, physicsClientId=CLIENT) elif target_quat is None: kinematic_conf = p.calculateInverseKinematics(robot, link, target_point, # lowerLimits=ll, upperLimits=ul, jointRanges=jr, restPoses=rp, jointDamping=jd, # solver=ikSolver, currentPosition=None, maxNumIterations=20, residualThreshold=-1, physicsClientId=CLIENT) else: kinematic_conf = p.calculateInverseKinematics(robot, link, target_point, target_quat, physicsClientId=CLIENT) if (kinematic_conf is None) or any(map(math.isnan, kinematic_conf)): return None constrain_joints = [2, 4, 5] pos, orn = target_pose[0], target_pose[1] orig_q = [] for i in range(p.getNumJoints(robot)): if p.getJointInfo(robot, i)[2] == 4: continue else: orig_q.append(p.getJointState(robot, i)[0]) lower = [-10.0, -10.0, -10.0, 0.0, -3.84, -1.57, 0.0, -2.62, -2.09, -1.92, -1.92, -0.798, -1.24, -0.798, -1.24] upper = [10.0, 10.0, 10.0, 0.345, 1.75, 0.52, 0.69, 0.0, 3.84, 1.22, 3.67, 1.24, 0.798, 1.24, 0.798] ranges = [20.0, 20.0, 20.0, 0.345, 5.59, 2.09, 0.69, 2.62, 5.93, 3.1399999999999997, 5.59, 2.0380000000000003, 2.0380000000000003, 2.0380000000000003, 2.0380000000000003] lowers, uppers, ranges = list(lower), list(upper), list(ranges) for i in constrain_joints: lowers[i] = orig_q[i] uppers[i] = orig_q[i] if use_null_space: kinematic_conf = p.calculateInverseKinematics(robot, link, targetPosition=pos, targetOrientation=orn, lowerLimits=lowers, upperLimits=uppers, jointRanges=ranges, restPoses=orig_q) else: kinematic_conf = p.calculateInverseKinematics(robot, link, targetPosition=pos, targetOrientation=orn, solver=0, maxNumIterations=1000, residualThreshold=1e-4) return kinematic_conf def is_pose_close(pose, target_pose, pos_tolerance=1e-3, ori_tolerance=1e-3*np.pi): (point, quat) = pose (target_point, target_quat) = target_pose if (target_point is not None) and not np.allclose(point, target_point, atol=pos_tolerance, rtol=0): return False if (target_quat is not None) and not np.allclose(quat, target_quat, atol=ori_tolerance, rtol=0): # TODO: account for quaternion redundancy return False return True def inverse_kinematics(robot, link, target_pose, max_iterations=200, max_time=INF, custom_limits={}, **kwargs): start_time = time.time() movable_joints = get_movable_joints(robot) for iteration in irange(max_iterations): if elapsed_time(start_time) >= max_time: return None kinematic_conf = inverse_kinematics_helper(robot, link, target_pose) if kinematic_conf is None: return None set_joint_positions(robot, movable_joints, kinematic_conf) if is_pose_close(get_link_pose(robot, link), target_pose, **kwargs): break lower_limits, upper_limits = get_custom_limits(robot, movable_joints, custom_limits) if not all_between(lower_limits, kinematic_conf, upper_limits): continue return kinematic_conf ##################################### def get_position_waypoints(start_point, direction, quat, step_size=0.01): distance = get_length(direction) unit_direction = get_unit_vector(direction) for t in np.arange(0, distance, step_size): point = start_point + t*unit_direction yield (point, quat) yield (start_point + direction, quat) def get_quaternion_waypoints(point, start_quat, end_quat, step_size=np.pi/16): angle = quat_angle_between(start_quat, end_quat) for t in np.arange(0, angle, step_size): fraction = t/angle quat = quat_combination(start_quat, end_quat, fraction=fraction) yield (point, quat) yield (point, end_quat) def get_pose_distance(pose1, pose2): pos1, quat1 = pose1 pos2, quat2 = pose2 pos_distance = get_distance(pos1, pos2) ori_distance = quat_angle_between(quat1, quat2) return pos_distance, ori_distance def interpolate_poses(pose1, pose2, pos_step_size=0.01, ori_step_size=np.pi/16): pos1, quat1 = pose1 pos2, quat2 = pose2 num_steps = max(2, int(math.ceil(max( np.divide(get_pose_distance(pose1, pose2), [pos_step_size, ori_step_size]))))) yield pose1 for w in np.linspace(0, 1, num=num_steps, endpoint=True)[1:-1]: pos = convex_combination(pos1, pos2, w=w) quat = quat_combination(quat1, quat2, fraction=w) yield (pos, quat) yield pose2 def interpolate(value1, value2, num_steps=2): num_steps = max(num_steps, 2) yield value1 for w in np.linspace(0, 1, num=num_steps, endpoint=True)[1:-1]: yield convex_combination(value1, value2, w=w) yield value2 def interpolate_waypoints(interpolate_fn, waypoints, returns_first=True): if len(waypoints) <= 1: for waypoint in waypoints: yield waypoint return yield waypoints[0] for waypoint1, waypoint2 in get_pairs(waypoints): for i, value in enumerate(interpolate_fn(waypoint1, waypoint2)): if returns_first and (i == 0): continue yield value # def workspace_trajectory(robot, link, start_point, direction, quat, **kwargs): # # TODO: pushing example # # TODO: just use current configuration? # # TODO: check collisions? # # TODO: lower intermediate tolerance # traj = [] # for pose in get_cartesian_waypoints(start_point, direction, quat): # conf = inverse_kinematics(robot, link, pose, **kwargs) # if conf is None: # return None # traj.append(conf) # return traj ##################################### NullSpace = namedtuple('Nullspace', ['lower', 'upper', 'range', 'rest']) def get_null_space(robot, joints, custom_limits={}): rest_positions = get_joint_positions(robot, joints) lower, upper = get_custom_limits(robot, joints, custom_limits) lower = np.maximum(lower, -10*np.ones(len(joints))) upper = np.minimum(upper, +10*np.ones(len(joints))) joint_ranges = 10*np.ones(len(joints)) return NullSpace(list(lower), list(upper), list(joint_ranges), list(rest_positions)) def create_sub_robot(robot, first_joint, target_link): # TODO: create a class or generator for repeated use selected_links = get_link_subtree(robot, first_joint) # TODO: child_link_from_joint? selected_joints = prune_fixed_joints(robot, selected_links) assert(target_link in selected_links) sub_target_link = selected_links.index(target_link) sub_robot = clone_body(robot, links=selected_links, visual=False, collision=False) # TODO: joint limits assert len(selected_joints) == len(get_movable_joints(sub_robot)) return sub_robot, selected_joints, sub_target_link def multiple_sub_inverse_kinematics(robot, first_joint, target_link, target_pose, max_attempts=1, max_solutions=INF, max_time=INF, custom_limits={}, first_close=True, **kwargs): # TODO: gradient descent using collision_info start_time = time.time() ancestor_joints = prune_fixed_joints(robot, get_ordered_ancestors(robot, target_link)) affected_joints = ancestor_joints[ancestor_joints.index(first_joint):] sub_robot, selected_joints, sub_target_link = create_sub_robot(robot, first_joint, target_link) # sub_joints = get_movable_joints(sub_robot) # sub_from_real = dict(safe_zip(sub_joints, selected_joints)) sub_joints = prune_fixed_joints(sub_robot, get_ordered_ancestors(sub_robot, sub_target_link)) selected_joints = affected_joints # sub_from_real = dict(safe_zip(sub_joints, selected_joints)) # sample_fn = get_sample_fn(sub_robot, sub_joints, custom_limits=custom_limits) # [-PI, PI] sample_fn = get_sample_fn(robot, selected_joints, custom_limits=custom_limits) # lower_limits, upper_limits = get_custom_limits(robot, get_movable_joints(robot), custom_limits) solutions = [] for attempt in irange(max_attempts): if (len(solutions) >= max_solutions) or (elapsed_time(start_time) >= max_time): break if not first_close or (attempt >= 1): # TODO: multiple seed confs sub_conf = sample_fn() set_joint_positions(sub_robot, sub_joints, sub_conf) sub_kinematic_conf = inverse_kinematics(sub_robot, sub_target_link, target_pose, max_time=max_time-elapsed_time(start_time), **kwargs) if sub_kinematic_conf is not None: # set_configuration(sub_robot, sub_kinematic_conf) sub_kinematic_conf = get_joint_positions(sub_robot, sub_joints) set_joint_positions(robot, selected_joints, sub_kinematic_conf) kinematic_conf = get_configuration(robot) # TODO: test on the resulting robot state (e.g. collisions) # if not all_between(lower_limits, kinematic_conf, upper_limits): solutions.append(kinematic_conf) # kinematic_conf | sub_kinematic_conf if solutions: set_configuration(robot, solutions[-1]) # TODO: test for redundant configurations remove_body(sub_robot) return solutions def plan_cartesian_motion(robot, first_joint, target_link, waypoint_poses, max_iterations=200, max_time=INF, custom_limits={}, **kwargs): # TODO: fix stationary joints # TODO: pass in set of movable joints and take least common ancestor # TODO: update with most recent bullet updates # https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/inverse_kinematics.py # https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/inverse_kinematics_husky_kuka.py # TODO: plan a path without needing to following intermediate waypoints lower_limits, upper_limits = get_custom_limits(robot, get_movable_joints(robot), custom_limits) sub_robot, selected_joints, sub_target_link = create_sub_robot(robot, first_joint, target_link) sub_joints = get_movable_joints(sub_robot) # null_space = get_null_space(robot, selected_joints, custom_limits=custom_limits) null_space = None solutions = [] for target_pose in waypoint_poses: start_time = time.time() for iteration in irange(max_iterations): if elapsed_time(start_time) >= max_time: remove_body(sub_robot) return None sub_kinematic_conf = inverse_kinematics_helper(sub_robot, sub_target_link, target_pose, null_space=null_space) if sub_kinematic_conf is None: remove_body(sub_robot) return None set_joint_positions(sub_robot, sub_joints, sub_kinematic_conf) if is_pose_close(get_link_pose(sub_robot, sub_target_link), target_pose, **kwargs): set_joint_positions(robot, selected_joints, sub_kinematic_conf) kinematic_conf = get_configuration(robot) if not all_between(lower_limits, kinematic_conf, upper_limits): # movable_joints = get_movable_joints(robot) # print([(get_joint_name(robot, j), l, v, u) for j, l, v, u in # zip(movable_joints, lower_limits, kinematic_conf, upper_limits) if not (l <= v <= u)]) # print("Limits violated") # wait_if_gui() remove_body(sub_robot) return None # print("IK iterations:", iteration) solutions.append(kinematic_conf) break else: remove_body(sub_robot) return None # TODO: finally: remove_body(sub_robot) return solutions def sub_inverse_kinematics(robot, first_joint, target_link, target_pose, **kwargs): solutions = plan_cartesian_motion(robot, first_joint, target_link, [target_pose], **kwargs) if solutions: return solutions[0] return None ##################################### def get_lifetime(lifetime): if lifetime is None: return 0 return lifetime def add_parameter(name, lower=0., upper=1., initial=0.): # TODO: make a slider that controls the step in the trajectory # TODO: could store a list of savers return p.addUserDebugParameter(name, lower, upper, initial, physicsClientId=CLIENT) def add_button(name, initial=False): # If Minimum value > maximum value a button instead of slider will appear # For a button, the value of getUserDebugParameter for a button increases 1 at each button press return add_parameter(name, lower=True, upper=False, initial=initial) def read_parameter(debug): return p.readUserDebugParameter(debug, physicsClientId=CLIENT) def read_counter(debug): return int(read_parameter(debug)) def read_button(debug): return read_counter(debug) % 2 == 1 def add_text(text, position=unit_point(), color=BLACK, lifetime=None, parent=NULL_ID, parent_link=BASE_LINK): return p.addUserDebugText(str(text), textPosition=position, textColorRGB=color[:3], # textSize=1, lifeTime=get_lifetime(lifetime), parentObjectUniqueId=parent, parentLinkIndex=parent_link, physicsClientId=CLIENT) def add_line(start, end, color=BLACK, width=1, lifetime=None, parent=NULL_ID, parent_link=BASE_LINK): assert (len(start) == 3) and (len(end) == 3) return p.addUserDebugLine(start, end, lineColorRGB=color[:3], lineWidth=width, lifeTime=get_lifetime(lifetime), parentObjectUniqueId=parent, parentLinkIndex=parent_link, physicsClientId=CLIENT) def remove_debug(debug): p.removeUserDebugItem(debug, physicsClientId=CLIENT) remove_handle = remove_debug def remove_handles(handles): with LockRenderer(): for handle in handles: remove_debug(handle) handles[:] = [] def remove_all_debug(): p.removeAllUserDebugItems(physicsClientId=CLIENT) def add_body_name(body, name=None, **kwargs): if name is None: name = get_name(body) with PoseSaver(body): set_pose(body, unit_pose()) lower, upper = get_aabb(body) # position = (0, 0, upper[2]) position = upper return add_text(name, position=position, parent=body, **kwargs) # removeUserDebugItem def add_segments(points, closed=False, **kwargs): # TODO: draw_segments lines = [] for v1, v2 in get_pairs(points): lines.append(add_line(v1, v2, **kwargs)) if closed: lines.append(add_line(points[-1], points[0], **kwargs)) return lines def draw_link_name(body, link=BASE_LINK): return add_text(get_link_name(body, link), position=(0, 0.2, 0), parent=body, parent_link=link) def draw_pose(pose, length=0.1, d=3, **kwargs): origin_world = tform_point(pose, np.zeros(3)) handles = [] for k in range(d): axis = np.zeros(3) axis[k] = 1 axis_world = tform_point(pose, length*axis) handles.append(add_line(origin_world, axis_world, color=axis, **kwargs)) return handles def draw_global_system(**kwargs): return draw_pose(Pose(), length=1., **kwargs) def draw_pose2d(pose2d, z=0., d=2, **kwargs): return draw_pose(pose_from_pose2d(pose2d, z), d=d, **kwargs) def draw_base_limits(limits, z=1e-2, **kwargs): lower, upper = limits vertices = [(lower[0], lower[1], z), (lower[0], upper[1], z), (upper[0], upper[1], z), (upper[0], lower[1], z)] return add_segments(vertices, closed=True, **kwargs) def get_circle_vertices(center, radius, n=24): vertices = [] for i in range(n): theta = i*2*math.pi/n unit = unit_from_theta(theta) if len(center) == 3: unit = np.append(unit, [0.]) vertices.append(center + radius*unit) return vertices def draw_circle(center, radius, n=24, **kwargs): return add_segments(get_circle_vertices(center, radius, n=n), closed=True, **kwargs) def draw_aabb(aabb, **kwargs): return [add_line(p1, p2, **kwargs) for p1, p2 in get_aabb_edges(aabb)] def draw_oobb(oobb, origin=False, **kwargs): aabb, pose = oobb handles = [] if origin: handles.extend(draw_pose(pose, **kwargs)) for edge in get_aabb_edges(aabb): p1, p2 = apply_affine(pose, edge) handles.append(add_line(p1, p2, **kwargs)) return handles def draw_point(point, size=0.01, **kwargs): lines = [] for i in range(len(point)): axis = np.zeros(len(point)) axis[i] = 1.0 p1 = np.array(point) - size/2 * axis p2 = np.array(point) + size/2 * axis lines.append(add_line(p1, p2, **kwargs)) return lines def get_face_edges(face): # return list(combinations(face, 2)) return get_wrapped_pairs(face) # TODO: lines versus planes def draw_mesh(mesh, **kwargs): verts, faces = mesh handles = [] with LockRenderer(): for face in faces: for i1, i2 in get_face_edges(face): handles.append(add_line(verts[i1], verts[i2], **kwargs)) return handles def was_ray_hit(ray_result): if ray_result is None: return False return ray_result.objectUniqueId != NULL_ID def get_hit_position(ray, ray_result=None): if was_ray_hit(ray_result): return ray_result.hit_position return ray.end def draw_ray(ray, ray_result=None, visible_color=GREEN, occluded_color=RED, **kwargs): if ray_result is None: return [add_line(ray.start, ray.end, color=visible_color, **kwargs)] hit_position = get_hit_position(ray, ray_result) return [ add_line(ray.start, hit_position, color=visible_color, **kwargs), add_line(hit_position, ray.end, color=occluded_color, **kwargs), ] ##################################### # Polygonal surfaces def create_rectangular_surface(width, length): # TODO: unify with rectangular_mesh extents = np.array([width, length, 0]) / 2. unit_corners = [(-1, -1), (+1, -1), (+1, +1), (-1, +1)] return [np.append(c, 0) * extents for c in unit_corners] def is_point_in_polygon(point, polygon): # TODO: rename polygon to path # TODO: is_point_in_polytope # TODO: aabb_contains_point sign = None for i in range(len(polygon)): v1, v2 = np.array(polygon[i - 1][:2]), np.array(polygon[i][:2]) delta = v2 - v1 normal = np.array([-delta[1], delta[0]]) dist = normal.dot(point[:2] - v1) if i == 0: # TODO: equality? sign = np.sign(dist) elif np.sign(dist) != sign: return False return True def distance_from_segment(x1, y1, x2, y2, x3, y3): # x3, y3 is the point # https://stackoverflow.com/questions/10983872/distance-from-a-point-to-a-polygon # https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment px = x2 - x1 py = y2 - y1 norm = px*px + py*py u = ((x3 - x1) * px + (y3 - y1) * py) / float(norm) if u > 1: u = 1 elif u < 0: u = 0 x = x1 + u * px y = y1 + u * py dx = x - x3 dy = y - y3 return math.sqrt(dx*dx + dy*dy) def tform_point(affine, point): return point_from_pose(multiply(affine, Pose(point=point))) def tform_points(affine, points): return [tform_point(affine, p) for p in points] apply_affine = tform_points def is_mesh_on_surface(polygon, world_from_surface, mesh, world_from_mesh, epsilon=1e-2): surface_from_mesh = multiply(invert(world_from_surface), world_from_mesh) points_surface = apply_affine(surface_from_mesh, mesh.vertices) min_z = np.min(points_surface[:, 2]) return (abs(min_z) < epsilon) and all(is_point_in_polygon(point, polygon) for point in points_surface) def is_point_on_surface(polygon, world_from_surface, point_world): [point_surface] = apply_affine(invert(world_from_surface), [point_world]) return is_point_in_polygon(point_surface, polygon[::-1]) def sample_polygon_tform(polygon, points): min_z = np.min(points[:, 2]) aabb_min = np.min(polygon, axis=0) aabb_max = np.max(polygon, axis=0) while True: x = np.random.uniform(aabb_min[0], aabb_max[0]) y = np.random.uniform(aabb_min[1], aabb_max[1]) theta = np.random.uniform(0, 2 * np.pi) point = Point(x, y, -min_z) quat = Euler(yaw=theta) surface_from_origin = Pose(point, quat) yield surface_from_origin # if all(is_point_in_polygon(p, polygon) for p in apply_affine(surface_from_origin, points)): # yield surface_from_origin def sample_surface_pose(polygon, world_from_surface, mesh): for surface_from_origin in sample_polygon_tform(polygon, mesh.vertices): world_from_mesh = multiply(world_from_surface, surface_from_origin) if is_mesh_on_surface(polygon, world_from_surface, mesh, world_from_mesh): yield world_from_mesh ##################################### # Sampling edges def sample_categorical(categories): from bisect import bisect names = categories.keys() cutoffs = np.cumsum([categories[name] for name in names])/sum(categories.values()) return names[bisect(cutoffs, np.random.random())] def sample_edge_point(polygon, radius): edges = get_wrapped_pairs(polygon) edge_weights = {i: max(get_length(v2 - v1) - 2 * radius, 0) for i, (v1, v2) in enumerate(edges)} # TODO: fail if no options while True: index = sample_categorical(edge_weights) v1, v2 = edges[index] t = np.random.uniform(radius, get_length(v2 - v1) - 2 * radius) yield t * get_unit_vector(v2 - v1) + v1 def get_closest_edge_point(polygon, point): # TODO: always pick perpendicular to the edge edges = get_wrapped_pairs(polygon) best = None for v1, v2 in edges: proj = (v2 - v1)[:2].dot((point - v1)[:2]) if proj <= 0: closest = v1 elif get_length((v2 - v1)[:2]) <= proj: closest = v2 else: closest = proj * get_unit_vector((v2 - v1)) if (best is None) or (get_length((point - closest)[:2]) < get_length((point - best)[:2])): best = closest return best def sample_edge_pose(polygon, world_from_surface, mesh): radius = max(get_length(v[:2]) for v in mesh.vertices) origin_from_base = Pose(Point(z=p.min(mesh.vertices[:, 2]))) for point in sample_edge_point(polygon, radius): theta = np.random.uniform(0, 2 * np.pi) surface_from_origin = Pose(point, Euler(yaw=theta)) yield multiply(world_from_surface, surface_from_origin, origin_from_base) ##################################### # Convex Hulls def convex_hull(points): from scipy.spatial import ConvexHull # TODO: cKDTree is faster, but KDTree can do all pairs closest hull = ConvexHull(list(points), incremental=False) new_indices = {i: ni for ni, i in enumerate(hull.vertices)} vertices = hull.points[hull.vertices, :] faces = np.vectorize(lambda i: new_indices[i])(hull.simplices) return Mesh(vertices.tolist(), faces.tolist()) def convex_signed_area(vertices): if len(vertices) < 3: return 0. vertices = [np.array(v[:2]) for v in vertices] segments = get_wrapped_pairs(vertices) return sum(np.cross(v1, v2) for v1, v2 in segments) / 2. def convex_area(vertices): return abs(convex_signed_area(vertices)) def convex_centroid(vertices): # TODO: also applies to non-overlapping polygons vertices = [np.array(v[:2]) for v in vertices] segments = get_wrapped_pairs(vertices) return sum((v1 + v2)*np.cross(v1, v2) for v1, v2 in segments) / (6.*convex_signed_area(vertices)) def get_normal(v1, v2, v3): return get_unit_vector(np.cross(np.array(v3) - v1, np.array(v2) - v1)) def get_rotation(v1, v2, v3): import scipy a1 = np.array(v3) - v1 a2 = np.array(v2) - v1 a3 = np.cross(a2, a1) return scipy.linalg.orth([a1, a2, a3]) def get_mesh_normal(face, interior): assert len(face) == 3 normal = get_normal(*face) if normal.dot(interior) > 0: normal *= -1 return normal def orient_face(vertices, face, point=None): if point is None: point = np.average(vertices, axis=0) v1, v2, v3 = vertices[face] normal = get_normal(v1, v2, v3) if normal.dot(point - v1) < 0: face = face[::-1] return tuple(face) def mesh_from_points(points, under=True): vertices, faces = map(np.array, convex_hull(points)) centroid = np.average(vertices, axis=0) new_faces = [orient_face(vertices, face, point=centroid) for face in faces] if under: new_faces.extend(map(tuple, map(reversed, list(new_faces)))) return Mesh(vertices.tolist(), new_faces) def rectangular_mesh(width, length): # TODO: 2.5d polygon extents = np.array([width, length, 0])/2. unit_corners = [(-1, -1), (+1, -1), (+1, +1), (-1, +1)] vertices = [np.append(c, [0])*extents for c in unit_corners] faces = [(0, 1, 2), (2, 3, 0)] return Mesh(vertices, faces) def tform_mesh(affine, mesh): return Mesh(apply_affine(affine, mesh.vertices), mesh.faces) def grow_polygon(points, radius=0., n=8): points2d = [point[:2] for point in points] if not points2d: return [] vertices = convex_hull(points2d).vertices if radius == 0: return vertices grown_points = [] for vertex in vertices: grown_points.append(vertex) for theta in np.linspace(0, 2*PI, num=n, endpoint=False): grown_points.append(vertex + radius * unit_from_theta(theta)) return convex_hull(grown_points).vertices ##################################### # Mesh & Pointcloud Files def obj_file_from_mesh(mesh, under=True): """ Creates a *.obj mesh string :param mesh: tuple of list of vertices and list of faces :return: *.obj mesh string """ vertices, faces = mesh s = 'g Mesh\n' # TODO: string writer for v in vertices: assert(len(v) == 3) s += '\nv {}'.format(' '.join(map(str, v))) for f in faces: # assert(len(f) == 3) # Not necessarily true f = [i+1 for i in f] # Assumes mesh is indexed from zero s += '\nf {}'.format(' '.join(map(str, f))) if under: s += '\nf {}'.format(' '.join(map(str, reversed(f)))) return s def get_connected_components(vertices, edges): undirected_edges = defaultdict(set) for v1, v2 in edges: undirected_edges[v1].add(v2) undirected_edges[v2].add(v1) clusters = [] processed = set() for v0 in vertices: if v0 in processed: continue processed.add(v0) cluster = {v0} queue = deque([v0]) while queue: v1 = queue.popleft() for v2 in (undirected_edges[v1] - processed): processed.add(v2) cluster.add(v2) queue.append(v2) if cluster: # preserves order clusters.append(frozenset(cluster)) return clusters def read_obj(path, decompose=True): mesh = Mesh([], []) meshes = {} vertices = [] faces = [] for line in read(path).split('\n'): tokens = line.split() if not tokens: continue if tokens[0] == 'o': name = tokens[1] mesh = Mesh([], []) meshes[name] = mesh elif tokens[0] == 'v': vertex = tuple(map(float, tokens[1:4])) vertices.append(vertex) elif tokens[0] in ('vn', 's'): pass elif tokens[0] == 'f': face = tuple(int(token.split('/')[0]) - 1 for token in tokens[1:]) faces.append(face) mesh.faces.append(face) if not decompose: return Mesh(vertices, faces) # TODO: separate into a standalone method # if not meshes: # # TODO: ensure this still works if no objects # meshes[None] = mesh # new_meshes = {} # TODO: make each triangle a separate object for name, mesh in meshes.items(): indices = sorted({i for face in mesh.faces for i in face}) mesh.vertices[:] = [vertices[i] for i in indices] new_index_from_old = {i2: i1 for i1, i2 in enumerate(indices)} mesh.faces[:] = [tuple(new_index_from_old[i1] for i1 in face) for face in mesh.faces] return meshes def read_stl(path, decompose=True): mesh = Mesh([], []) meshes = {} data = trimesh.load_mesh(path, enable_post_processing=True, solid=True) faces = data.faces vertices = data.vertices if not decompose: mesh_data = Mesh(vertices, faces) return mesh_data for name, mesh in meshes.items(): indices = sorted({i for face in mesh.faces for i in face}) mesh.vertices[:] = [vertices[i] for i in indices] new_index_from_old = {i2: i1 for i1, i2 in enumerate(indices)} mesh.faces[:] = [tuple(new_index_from_old[i1] for i1 in face) for face in mesh.faces] return meshes def transform_obj_file(obj_string, transformation): new_lines = [] for line in obj_string.split('\n'): tokens = line.split() if not tokens or (tokens[0] != 'v'): new_lines.append(line) continue vertex = list(map(float, tokens[1:])) transformed_vertex = transformation.dot(vertex) new_lines.append('v {}'.format(' '.join(map(str, transformed_vertex)))) return '\n'.join(new_lines) def read_mesh_off(path, scale=1.0): """ Reads a *.off mesh file :param path: path to the *.off mesh file :return: tuple of list of vertices and list of faces """ with open(path) as f: assert (f.readline().split()[0] == 'OFF'), 'Not OFF file' nv, nf, ne = [int(x) for x in f.readline().split()] verts = [tuple(scale * float(v) for v in f.readline().split()) for _ in range(nv)] faces = [tuple(map(int, f.readline().split()[1:])) for _ in range(nf)] return Mesh(verts, faces) def read_pcd_file(path): """ Reads a *.pcd pointcloud file :param path: path to the *.pcd pointcloud file :return: list of points """ with open(path) as f: data = f.readline().split() num_points = 0 while data[0] != 'DATA': if data[0] == 'POINTS': num_points = int(data[1]) data = f.readline().split() continue return [tuple(map(float, f.readline().split())) for _ in range(num_points)] # TODO: factor out things that don't depend on pybullet ##################################### # https://github.com/kohterai/OBJ-Parser """ def readWrl(filename, name='wrlObj', scale=1.0, color='black'): def readOneObj(): vl = [] while True: line = fl.readline() split = line.split(',') if len(split) != 2: break split = split[0].split() if len(split) == 3: vl.append(np.array([scale*float(x) for x in split]+[1.0])) else: break print ' verts', len(vl), verts = np.vstack(vl).T while line.split()[0] != 'coordIndex': line = fl.readline() line = fl.readline() faces = [] while True: line = fl.readline() split = line.split(',') if len(split) > 3: faces.append(np.array([int(x) for x in split[:3]])) else: break print 'faces', len(faces) return Prim(verts, faces, hu.Pose(0,0,0,0), None, name=name+str(len(prims))) fl = open(filename) assert fl.readline().split()[0] == '#VRML', 'Not VRML file?' prims = [] while True: line = fl.readline() if not line: break split = line.split() if not split or split[0] != 'point': continue else: print 'Object', len(prims) prims.append(readOneObj()) # Have one "part" so that shadows are simpler part = Shape(prims, None, name=name+'_part') # Keep color only in top entry. return Shape([part], None, name=name, color=color) """
181,993
Python
36.278574
174
0.626991
makolon/hsr_isaac_tamp/hsr_tamp/experiments/env_3d/utils/pybullet_tools/pr2_never_collisions.py
# TODO: maybe some OpenRAVE links are disabled # http://openrave.org/docs/0.8.2/collada_robot_extensions/ # < extra # type = "collision" > # < technique # profile = "OpenRAVE" # ignore_link_pair NEVER_COLLISIONS = [('base_bellow_link', 'base_footprint'), ('base_bellow_link', 'bl_caster_l_wheel_link'), ('base_bellow_link', 'bl_caster_r_wheel_link'), ('base_bellow_link', 'bl_caster_rotation_link'), ('base_bellow_link', 'br_caster_l_wheel_link'), ('base_bellow_link', 'br_caster_r_wheel_link'), ('base_bellow_link', 'br_caster_rotation_link'), ('base_bellow_link', 'double_stereo_link'), ('base_bellow_link', 'fl_caster_l_wheel_link'), ('base_bellow_link', 'fl_caster_r_wheel_link'), ('base_bellow_link', 'fl_caster_rotation_link'), ('base_bellow_link', 'fr_caster_l_wheel_link'), ('base_bellow_link', 'fr_caster_r_wheel_link'), ('base_bellow_link', 'fr_caster_rotation_link'), ('base_bellow_link', 'head_pan_link'), ('base_bellow_link', 'head_plate_frame'), ('base_bellow_link', 'head_tilt_link'), ('base_bellow_link', 'l_elbow_flex_link'), ('base_bellow_link', 'l_forearm_link'), ('base_bellow_link', 'l_forearm_roll_link'), ('base_bellow_link', 'l_gripper_motor_accelerometer_link'), ('base_bellow_link', 'l_shoulder_lift_link'), ('base_bellow_link', 'l_shoulder_pan_link'), ('base_bellow_link', 'l_upper_arm_link'), ('base_bellow_link', 'l_upper_arm_roll_link'), ('base_bellow_link', 'l_wrist_roll_link'), ('base_bellow_link', 'laser_tilt_mount_link'), ('base_bellow_link', 'r_elbow_flex_link'), ('base_bellow_link', 'r_forearm_link'), ('base_bellow_link', 'r_forearm_roll_link'), ('base_bellow_link', 'r_gripper_motor_accelerometer_link'), ('base_bellow_link', 'r_shoulder_lift_link'), ('base_bellow_link', 'r_shoulder_pan_link'), ('base_bellow_link', 'r_upper_arm_link'), ('base_bellow_link', 'r_upper_arm_roll_link'), ('base_bellow_link', 'r_wrist_flex_link'), ('base_bellow_link', 'r_wrist_roll_link'), ('base_bellow_link', 'sensor_mount_link'), ('base_footprint', 'bl_caster_l_wheel_link'), ('base_footprint', 'bl_caster_r_wheel_link'), ('base_footprint', 'bl_caster_rotation_link'), ('base_footprint', 'br_caster_l_wheel_link'), ('base_footprint', 'br_caster_r_wheel_link'), ('base_footprint', 'br_caster_rotation_link'), ('base_footprint', 'double_stereo_link'), ('base_footprint', 'fl_caster_l_wheel_link'), ('base_footprint', 'fl_caster_r_wheel_link'), ('base_footprint', 'fl_caster_rotation_link'), ('base_footprint', 'fr_caster_l_wheel_link'), ('base_footprint', 'fr_caster_r_wheel_link'), ('base_footprint', 'fr_caster_rotation_link'), ('base_footprint', 'head_pan_link'), ('base_footprint', 'head_plate_frame'), ('base_footprint', 'head_tilt_link'), ('base_footprint', 'l_elbow_flex_link'), ('base_footprint', 'l_forearm_link'), ('base_footprint', 'l_forearm_roll_link'), ('base_footprint', 'l_gripper_l_finger_link'), ('base_footprint', 'l_gripper_l_finger_tip_link'), ('base_footprint', 'l_gripper_motor_accelerometer_link'), ('base_footprint', 'l_gripper_palm_link'), ('base_footprint', 'l_gripper_r_finger_link'), ('base_footprint', 'l_gripper_r_finger_tip_link'), ('base_footprint', 'l_shoulder_lift_link'), ('base_footprint', 'l_shoulder_pan_link'), ('base_footprint', 'l_upper_arm_link'), ('base_footprint', 'l_upper_arm_roll_link'), ('base_footprint', 'l_wrist_flex_link'), ('base_footprint', 'l_wrist_roll_link'), ('base_footprint', 'laser_tilt_mount_link'), ('base_footprint', 'r_elbow_flex_link'), ('base_footprint', 'r_forearm_link'), ('base_footprint', 'r_forearm_roll_link'), ('base_footprint', 'r_gripper_l_finger_link'), ('base_footprint', 'r_gripper_l_finger_tip_link'), ('base_footprint', 'r_gripper_motor_accelerometer_link'), ('base_footprint', 'r_gripper_palm_link'), ('base_footprint', 'r_gripper_r_finger_link'), ('base_footprint', 'r_gripper_r_finger_tip_link'), ('base_footprint', 'r_shoulder_lift_link'), ('base_footprint', 'r_shoulder_pan_link'), ('base_footprint', 'r_upper_arm_link'), ('base_footprint', 'r_upper_arm_roll_link'), ('base_footprint', 'r_wrist_flex_link'), ('base_footprint', 'r_wrist_roll_link'), ('base_footprint', 'sensor_mount_link'), ('base_footprint', 'torso_lift_link'), ('base_link', 'double_stereo_link'), ('base_link', 'head_pan_link'), ('base_link', 'head_plate_frame'), ('base_link', 'head_tilt_link'), ('base_link', 'l_shoulder_lift_link'), ('base_link', 'l_shoulder_pan_link'), ('base_link', 'l_upper_arm_link'), ('base_link', 'l_upper_arm_roll_link'), ('base_link', 'laser_tilt_mount_link'), ('base_link', 'r_shoulder_lift_link'), ('base_link', 'r_shoulder_pan_link'), ('base_link', 'r_upper_arm_link'), ('base_link', 'r_upper_arm_roll_link'), ('base_link', 'sensor_mount_link'), ('bl_caster_l_wheel_link', 'bl_caster_r_wheel_link'), ('bl_caster_l_wheel_link', 'br_caster_l_wheel_link'), ('bl_caster_l_wheel_link', 'br_caster_r_wheel_link'), ('bl_caster_l_wheel_link', 'br_caster_rotation_link'), ('bl_caster_l_wheel_link', 'double_stereo_link'), ('bl_caster_l_wheel_link', 'fl_caster_l_wheel_link'), ('bl_caster_l_wheel_link', 'fl_caster_r_wheel_link'), ('bl_caster_l_wheel_link', 'fl_caster_rotation_link'), ('bl_caster_l_wheel_link', 'fr_caster_l_wheel_link'), ('bl_caster_l_wheel_link', 'fr_caster_r_wheel_link'), ('bl_caster_l_wheel_link', 'fr_caster_rotation_link'), ('bl_caster_l_wheel_link', 'head_pan_link'), ('bl_caster_l_wheel_link', 'head_plate_frame'), ('bl_caster_l_wheel_link', 'head_tilt_link'), ('bl_caster_l_wheel_link', 'l_elbow_flex_link'), ('bl_caster_l_wheel_link', 'l_forearm_link'), ('bl_caster_l_wheel_link', 'l_forearm_roll_link'), ('bl_caster_l_wheel_link', 'l_gripper_motor_accelerometer_link'), ('bl_caster_l_wheel_link', 'l_shoulder_lift_link'), ('bl_caster_l_wheel_link', 'l_shoulder_pan_link'), ('bl_caster_l_wheel_link', 'l_upper_arm_link'), ('bl_caster_l_wheel_link', 'l_upper_arm_roll_link'), ('bl_caster_l_wheel_link', 'l_wrist_roll_link'), ('bl_caster_l_wheel_link', 'laser_tilt_mount_link'), ('bl_caster_l_wheel_link', 'r_elbow_flex_link'), ('bl_caster_l_wheel_link', 'r_forearm_link'), ('bl_caster_l_wheel_link', 'r_forearm_roll_link'), ('bl_caster_l_wheel_link', 'r_gripper_l_finger_link'), ('bl_caster_l_wheel_link', 'r_gripper_l_finger_tip_link'), ('bl_caster_l_wheel_link', 'r_gripper_motor_accelerometer_link'), ('bl_caster_l_wheel_link', 'r_gripper_palm_link'), ('bl_caster_l_wheel_link', 'r_gripper_r_finger_link'), ('bl_caster_l_wheel_link', 'r_gripper_r_finger_tip_link'), ('bl_caster_l_wheel_link', 'r_shoulder_lift_link'), ('bl_caster_l_wheel_link', 'r_shoulder_pan_link'), ('bl_caster_l_wheel_link', 'r_upper_arm_link'), ('bl_caster_l_wheel_link', 'r_upper_arm_roll_link'), ('bl_caster_l_wheel_link', 'r_wrist_flex_link'), ('bl_caster_l_wheel_link', 'r_wrist_roll_link'), ('bl_caster_l_wheel_link', 'sensor_mount_link'), ('bl_caster_l_wheel_link', 'torso_lift_link'), ('bl_caster_r_wheel_link', 'br_caster_l_wheel_link'), ('bl_caster_r_wheel_link', 'br_caster_r_wheel_link'), ('bl_caster_r_wheel_link', 'br_caster_rotation_link'), ('bl_caster_r_wheel_link', 'double_stereo_link'), ('bl_caster_r_wheel_link', 'fl_caster_l_wheel_link'), ('bl_caster_r_wheel_link', 'fl_caster_r_wheel_link'), ('bl_caster_r_wheel_link', 'fl_caster_rotation_link'), ('bl_caster_r_wheel_link', 'fr_caster_l_wheel_link'), ('bl_caster_r_wheel_link', 'fr_caster_r_wheel_link'), ('bl_caster_r_wheel_link', 'fr_caster_rotation_link'), ('bl_caster_r_wheel_link', 'head_pan_link'), ('bl_caster_r_wheel_link', 'head_plate_frame'), ('bl_caster_r_wheel_link', 'head_tilt_link'), ('bl_caster_r_wheel_link', 'l_elbow_flex_link'), ('bl_caster_r_wheel_link', 'l_forearm_roll_link'), ('bl_caster_r_wheel_link', 'l_gripper_motor_accelerometer_link'), ('bl_caster_r_wheel_link', 'l_shoulder_lift_link'), ('bl_caster_r_wheel_link', 'l_shoulder_pan_link'), ('bl_caster_r_wheel_link', 'l_upper_arm_link'), ('bl_caster_r_wheel_link', 'l_upper_arm_roll_link'), ('bl_caster_r_wheel_link', 'laser_tilt_mount_link'), ('bl_caster_r_wheel_link', 'r_elbow_flex_link'), ('bl_caster_r_wheel_link', 'r_forearm_link'), ('bl_caster_r_wheel_link', 'r_forearm_roll_link'), ('bl_caster_r_wheel_link', 'r_gripper_l_finger_link'), ('bl_caster_r_wheel_link', 'r_gripper_l_finger_tip_link'), ('bl_caster_r_wheel_link', 'r_gripper_motor_accelerometer_link'), ('bl_caster_r_wheel_link', 'r_gripper_palm_link'), ('bl_caster_r_wheel_link', 'r_gripper_r_finger_link'), ('bl_caster_r_wheel_link', 'r_gripper_r_finger_tip_link'), ('bl_caster_r_wheel_link', 'r_shoulder_lift_link'), ('bl_caster_r_wheel_link', 'r_shoulder_pan_link'), ('bl_caster_r_wheel_link', 'r_upper_arm_link'), ('bl_caster_r_wheel_link', 'r_upper_arm_roll_link'), ('bl_caster_r_wheel_link', 'r_wrist_flex_link'), ('bl_caster_r_wheel_link', 'r_wrist_roll_link'), ('bl_caster_r_wheel_link', 'sensor_mount_link'), ('bl_caster_r_wheel_link', 'torso_lift_link'), ('bl_caster_rotation_link', 'br_caster_l_wheel_link'), ('bl_caster_rotation_link', 'br_caster_r_wheel_link'), ('bl_caster_rotation_link', 'br_caster_rotation_link'), ('bl_caster_rotation_link', 'double_stereo_link'), ('bl_caster_rotation_link', 'fl_caster_l_wheel_link'), ('bl_caster_rotation_link', 'fl_caster_r_wheel_link'), ('bl_caster_rotation_link', 'fl_caster_rotation_link'), ('bl_caster_rotation_link', 'fr_caster_l_wheel_link'), ('bl_caster_rotation_link', 'fr_caster_r_wheel_link'), ('bl_caster_rotation_link', 'fr_caster_rotation_link'), ('bl_caster_rotation_link', 'head_pan_link'), ('bl_caster_rotation_link', 'head_plate_frame'), ('bl_caster_rotation_link', 'head_tilt_link'), ('bl_caster_rotation_link', 'l_elbow_flex_link'), ('bl_caster_rotation_link', 'l_forearm_roll_link'), ('bl_caster_rotation_link', 'l_shoulder_lift_link'), ('bl_caster_rotation_link', 'l_shoulder_pan_link'), ('bl_caster_rotation_link', 'l_upper_arm_link'), ('bl_caster_rotation_link', 'l_upper_arm_roll_link'), ('bl_caster_rotation_link', 'laser_tilt_mount_link'), ('bl_caster_rotation_link', 'r_elbow_flex_link'), ('bl_caster_rotation_link', 'r_forearm_link'), ('bl_caster_rotation_link', 'r_forearm_roll_link'), ('bl_caster_rotation_link', 'r_gripper_l_finger_link'), ('bl_caster_rotation_link', 'r_gripper_l_finger_tip_link'), ('bl_caster_rotation_link', 'r_gripper_motor_accelerometer_link'), ('bl_caster_rotation_link', 'r_gripper_palm_link'), ('bl_caster_rotation_link', 'r_gripper_r_finger_link'), ('bl_caster_rotation_link', 'r_shoulder_lift_link'), ('bl_caster_rotation_link', 'r_shoulder_pan_link'), ('bl_caster_rotation_link', 'r_upper_arm_link'), ('bl_caster_rotation_link', 'r_upper_arm_roll_link'), ('bl_caster_rotation_link', 'r_wrist_flex_link'), ('bl_caster_rotation_link', 'r_wrist_roll_link'), ('bl_caster_rotation_link', 'sensor_mount_link'), ('bl_caster_rotation_link', 'torso_lift_link'), ('br_caster_l_wheel_link', 'br_caster_r_wheel_link'), ('br_caster_l_wheel_link', 'double_stereo_link'), ('br_caster_l_wheel_link', 'fl_caster_l_wheel_link'), ('br_caster_l_wheel_link', 'fl_caster_r_wheel_link'), ('br_caster_l_wheel_link', 'fl_caster_rotation_link'), ('br_caster_l_wheel_link', 'fr_caster_l_wheel_link'), ('br_caster_l_wheel_link', 'fr_caster_r_wheel_link'), ('br_caster_l_wheel_link', 'fr_caster_rotation_link'), ('br_caster_l_wheel_link', 'head_pan_link'), ('br_caster_l_wheel_link', 'head_plate_frame'), ('br_caster_l_wheel_link', 'head_tilt_link'), ('br_caster_l_wheel_link', 'l_elbow_flex_link'), ('br_caster_l_wheel_link', 'l_forearm_link'), ('br_caster_l_wheel_link', 'l_forearm_roll_link'), ('br_caster_l_wheel_link', 'l_gripper_l_finger_link'), ('br_caster_l_wheel_link', 'l_gripper_l_finger_tip_link'), ('br_caster_l_wheel_link', 'l_gripper_motor_accelerometer_link'), ('br_caster_l_wheel_link', 'l_gripper_palm_link'), ('br_caster_l_wheel_link', 'l_gripper_r_finger_link'), ('br_caster_l_wheel_link', 'l_gripper_r_finger_tip_link'), ('br_caster_l_wheel_link', 'l_shoulder_lift_link'), ('br_caster_l_wheel_link', 'l_shoulder_pan_link'), ('br_caster_l_wheel_link', 'l_upper_arm_link'), ('br_caster_l_wheel_link', 'l_upper_arm_roll_link'), ('br_caster_l_wheel_link', 'l_wrist_flex_link'), ('br_caster_l_wheel_link', 'l_wrist_roll_link'), ('br_caster_l_wheel_link', 'laser_tilt_mount_link'), ('br_caster_l_wheel_link', 'r_elbow_flex_link'), ('br_caster_l_wheel_link', 'r_forearm_roll_link'), ('br_caster_l_wheel_link', 'r_gripper_motor_accelerometer_link'), ('br_caster_l_wheel_link', 'r_shoulder_lift_link'), ('br_caster_l_wheel_link', 'r_shoulder_pan_link'), ('br_caster_l_wheel_link', 'r_upper_arm_link'), ('br_caster_l_wheel_link', 'r_upper_arm_roll_link'), ('br_caster_l_wheel_link', 'sensor_mount_link'), ('br_caster_l_wheel_link', 'torso_lift_link'), ('br_caster_r_wheel_link', 'double_stereo_link'), ('br_caster_r_wheel_link', 'fl_caster_l_wheel_link'), ('br_caster_r_wheel_link', 'fl_caster_r_wheel_link'), ('br_caster_r_wheel_link', 'fl_caster_rotation_link'), ('br_caster_r_wheel_link', 'fr_caster_l_wheel_link'), ('br_caster_r_wheel_link', 'fr_caster_r_wheel_link'), ('br_caster_r_wheel_link', 'fr_caster_rotation_link'), ('br_caster_r_wheel_link', 'head_pan_link'), ('br_caster_r_wheel_link', 'head_plate_frame'), ('br_caster_r_wheel_link', 'head_tilt_link'), ('br_caster_r_wheel_link', 'l_elbow_flex_link'), ('br_caster_r_wheel_link', 'l_forearm_link'), ('br_caster_r_wheel_link', 'l_forearm_roll_link'), ('br_caster_r_wheel_link', 'l_gripper_l_finger_link'), ('br_caster_r_wheel_link', 'l_gripper_l_finger_tip_link'), ('br_caster_r_wheel_link', 'l_gripper_motor_accelerometer_link'), ('br_caster_r_wheel_link', 'l_gripper_palm_link'), ('br_caster_r_wheel_link', 'l_gripper_r_finger_link'), ('br_caster_r_wheel_link', 'l_gripper_r_finger_tip_link'), ('br_caster_r_wheel_link', 'l_shoulder_lift_link'), ('br_caster_r_wheel_link', 'l_shoulder_pan_link'), ('br_caster_r_wheel_link', 'l_upper_arm_link'), ('br_caster_r_wheel_link', 'l_upper_arm_roll_link'), ('br_caster_r_wheel_link', 'l_wrist_flex_link'), ('br_caster_r_wheel_link', 'l_wrist_roll_link'), ('br_caster_r_wheel_link', 'laser_tilt_mount_link'), ('br_caster_r_wheel_link', 'r_elbow_flex_link'), ('br_caster_r_wheel_link', 'r_forearm_roll_link'), ('br_caster_r_wheel_link', 'r_gripper_motor_accelerometer_link'), ('br_caster_r_wheel_link', 'r_shoulder_lift_link'), ('br_caster_r_wheel_link', 'r_shoulder_pan_link'), ('br_caster_r_wheel_link', 'r_upper_arm_link'), ('br_caster_r_wheel_link', 'r_upper_arm_roll_link'), ('br_caster_r_wheel_link', 'sensor_mount_link'), ('br_caster_r_wheel_link', 'torso_lift_link'), ('br_caster_rotation_link', 'double_stereo_link'), ('br_caster_rotation_link', 'fl_caster_l_wheel_link'), ('br_caster_rotation_link', 'fl_caster_r_wheel_link'), ('br_caster_rotation_link', 'fl_caster_rotation_link'), ('br_caster_rotation_link', 'fr_caster_l_wheel_link'), ('br_caster_rotation_link', 'fr_caster_r_wheel_link'), ('br_caster_rotation_link', 'fr_caster_rotation_link'), ('br_caster_rotation_link', 'head_pan_link'), ('br_caster_rotation_link', 'head_plate_frame'), ('br_caster_rotation_link', 'head_tilt_link'), ('br_caster_rotation_link', 'l_elbow_flex_link'), ('br_caster_rotation_link', 'l_forearm_link'), ('br_caster_rotation_link', 'l_forearm_roll_link'), ('br_caster_rotation_link', 'l_gripper_motor_accelerometer_link'), ('br_caster_rotation_link', 'l_gripper_palm_link'), ('br_caster_rotation_link', 'l_gripper_r_finger_link'), ('br_caster_rotation_link', 'l_gripper_r_finger_tip_link'), ('br_caster_rotation_link', 'l_shoulder_lift_link'), ('br_caster_rotation_link', 'l_shoulder_pan_link'), ('br_caster_rotation_link', 'l_upper_arm_link'), ('br_caster_rotation_link', 'l_upper_arm_roll_link'), ('br_caster_rotation_link', 'l_wrist_flex_link'), ('br_caster_rotation_link', 'l_wrist_roll_link'), ('br_caster_rotation_link', 'laser_tilt_mount_link'), ('br_caster_rotation_link', 'r_elbow_flex_link'), ('br_caster_rotation_link', 'r_forearm_roll_link'), ('br_caster_rotation_link', 'r_gripper_motor_accelerometer_link'), ('br_caster_rotation_link', 'r_shoulder_lift_link'), ('br_caster_rotation_link', 'r_shoulder_pan_link'), ('br_caster_rotation_link', 'r_upper_arm_link'), ('br_caster_rotation_link', 'r_upper_arm_roll_link'), ('br_caster_rotation_link', 'sensor_mount_link'), ('br_caster_rotation_link', 'torso_lift_link'), ('double_stereo_link', 'fl_caster_l_wheel_link'), ('double_stereo_link', 'fl_caster_r_wheel_link'), ('double_stereo_link', 'fl_caster_rotation_link'), ('double_stereo_link', 'fr_caster_l_wheel_link'), ('double_stereo_link', 'fr_caster_r_wheel_link'), ('double_stereo_link', 'fr_caster_rotation_link'), ('double_stereo_link', 'l_elbow_flex_link'), ('double_stereo_link', 'l_forearm_link'), ('double_stereo_link', 'l_forearm_roll_link'), ('double_stereo_link', 'l_gripper_l_finger_link'), ('double_stereo_link', 'l_gripper_l_finger_tip_link'), ('double_stereo_link', 'l_gripper_motor_accelerometer_link'), ('double_stereo_link', 'l_shoulder_lift_link'), ('double_stereo_link', 'l_shoulder_pan_link'), ('double_stereo_link', 'l_upper_arm_link'), ('double_stereo_link', 'l_upper_arm_roll_link'), ('double_stereo_link', 'l_wrist_flex_link'), ('double_stereo_link', 'l_wrist_roll_link'), ('double_stereo_link', 'laser_tilt_mount_link'), ('double_stereo_link', 'r_elbow_flex_link'), ('double_stereo_link', 'r_forearm_link'), ('double_stereo_link', 'r_forearm_roll_link'), ('double_stereo_link', 'r_gripper_l_finger_link'), ('double_stereo_link', 'r_gripper_l_finger_tip_link'), ('double_stereo_link', 'r_gripper_motor_accelerometer_link'), ('double_stereo_link', 'r_gripper_palm_link'), ('double_stereo_link', 'r_gripper_r_finger_link'), ('double_stereo_link', 'r_gripper_r_finger_tip_link'), ('double_stereo_link', 'r_shoulder_lift_link'), ('double_stereo_link', 'r_shoulder_pan_link'), ('double_stereo_link', 'r_upper_arm_link'), ('double_stereo_link', 'r_upper_arm_roll_link'), ('double_stereo_link', 'r_wrist_flex_link'), ('double_stereo_link', 'r_wrist_roll_link'), ('double_stereo_link', 'torso_lift_link'), ('fl_caster_l_wheel_link', 'fl_caster_r_wheel_link'), ('fl_caster_l_wheel_link', 'fr_caster_l_wheel_link'), ('fl_caster_l_wheel_link', 'fr_caster_r_wheel_link'), ('fl_caster_l_wheel_link', 'fr_caster_rotation_link'), ('fl_caster_l_wheel_link', 'head_pan_link'), ('fl_caster_l_wheel_link', 'head_plate_frame'), ('fl_caster_l_wheel_link', 'head_tilt_link'), ('fl_caster_l_wheel_link', 'l_elbow_flex_link'), ('fl_caster_l_wheel_link', 'l_forearm_roll_link'), ('fl_caster_l_wheel_link', 'l_shoulder_lift_link'), ('fl_caster_l_wheel_link', 'l_shoulder_pan_link'), ('fl_caster_l_wheel_link', 'l_upper_arm_link'), ('fl_caster_l_wheel_link', 'l_upper_arm_roll_link'), ('fl_caster_l_wheel_link', 'laser_tilt_mount_link'), ('fl_caster_l_wheel_link', 'r_elbow_flex_link'), ('fl_caster_l_wheel_link', 'r_forearm_link'), ('fl_caster_l_wheel_link', 'r_forearm_roll_link'), ('fl_caster_l_wheel_link', 'r_gripper_motor_accelerometer_link'), ('fl_caster_l_wheel_link', 'r_shoulder_lift_link'), ('fl_caster_l_wheel_link', 'r_shoulder_pan_link'), ('fl_caster_l_wheel_link', 'r_upper_arm_link'), ('fl_caster_l_wheel_link', 'r_upper_arm_roll_link'), ('fl_caster_l_wheel_link', 'r_wrist_flex_link'), ('fl_caster_l_wheel_link', 'r_wrist_roll_link'), ('fl_caster_l_wheel_link', 'sensor_mount_link'), ('fl_caster_l_wheel_link', 'torso_lift_link'), ('fl_caster_r_wheel_link', 'fr_caster_l_wheel_link'), ('fl_caster_r_wheel_link', 'fr_caster_r_wheel_link'), ('fl_caster_r_wheel_link', 'fr_caster_rotation_link'), ('fl_caster_r_wheel_link', 'head_pan_link'), ('fl_caster_r_wheel_link', 'head_plate_frame'), ('fl_caster_r_wheel_link', 'head_tilt_link'), ('fl_caster_r_wheel_link', 'l_elbow_flex_link'), ('fl_caster_r_wheel_link', 'l_forearm_roll_link'), ('fl_caster_r_wheel_link', 'l_shoulder_lift_link'), ('fl_caster_r_wheel_link', 'l_shoulder_pan_link'), ('fl_caster_r_wheel_link', 'l_upper_arm_link'), ('fl_caster_r_wheel_link', 'l_upper_arm_roll_link'), ('fl_caster_r_wheel_link', 'laser_tilt_mount_link'), ('fl_caster_r_wheel_link', 'r_elbow_flex_link'), ('fl_caster_r_wheel_link', 'r_forearm_link'), ('fl_caster_r_wheel_link', 'r_forearm_roll_link'), ('fl_caster_r_wheel_link', 'r_gripper_motor_accelerometer_link'), ('fl_caster_r_wheel_link', 'r_shoulder_lift_link'), ('fl_caster_r_wheel_link', 'r_shoulder_pan_link'), ('fl_caster_r_wheel_link', 'r_upper_arm_link'), ('fl_caster_r_wheel_link', 'r_upper_arm_roll_link'), ('fl_caster_r_wheel_link', 'r_wrist_flex_link'), ('fl_caster_r_wheel_link', 'r_wrist_roll_link'), ('fl_caster_r_wheel_link', 'sensor_mount_link'), ('fl_caster_r_wheel_link', 'torso_lift_link'), ('fl_caster_rotation_link', 'fr_caster_l_wheel_link'), ('fl_caster_rotation_link', 'fr_caster_r_wheel_link'), ('fl_caster_rotation_link', 'fr_caster_rotation_link'), ('fl_caster_rotation_link', 'head_pan_link'), ('fl_caster_rotation_link', 'head_plate_frame'), ('fl_caster_rotation_link', 'head_tilt_link'), ('fl_caster_rotation_link', 'l_elbow_flex_link'), ('fl_caster_rotation_link', 'l_forearm_roll_link'), ('fl_caster_rotation_link', 'l_shoulder_lift_link'), ('fl_caster_rotation_link', 'l_shoulder_pan_link'), ('fl_caster_rotation_link', 'l_upper_arm_link'), ('fl_caster_rotation_link', 'l_upper_arm_roll_link'), ('fl_caster_rotation_link', 'laser_tilt_mount_link'), ('fl_caster_rotation_link', 'r_elbow_flex_link'), ('fl_caster_rotation_link', 'r_forearm_roll_link'), ('fl_caster_rotation_link', 'r_gripper_motor_accelerometer_link'), ('fl_caster_rotation_link', 'r_shoulder_lift_link'), ('fl_caster_rotation_link', 'r_shoulder_pan_link'), ('fl_caster_rotation_link', 'r_upper_arm_link'), ('fl_caster_rotation_link', 'r_upper_arm_roll_link'), ('fl_caster_rotation_link', 'sensor_mount_link'), ('fl_caster_rotation_link', 'torso_lift_link'), ('fr_caster_l_wheel_link', 'fr_caster_r_wheel_link'), ('fr_caster_l_wheel_link', 'head_pan_link'), ('fr_caster_l_wheel_link', 'head_plate_frame'), ('fr_caster_l_wheel_link', 'head_tilt_link'), ('fr_caster_l_wheel_link', 'l_elbow_flex_link'), ('fr_caster_l_wheel_link', 'l_forearm_link'), ('fr_caster_l_wheel_link', 'l_forearm_roll_link'), ('fr_caster_l_wheel_link', 'l_gripper_motor_accelerometer_link'), ('fr_caster_l_wheel_link', 'l_shoulder_lift_link'), ('fr_caster_l_wheel_link', 'l_shoulder_pan_link'), ('fr_caster_l_wheel_link', 'l_upper_arm_link'), ('fr_caster_l_wheel_link', 'l_upper_arm_roll_link'), ('fr_caster_l_wheel_link', 'l_wrist_flex_link'), ('fr_caster_l_wheel_link', 'l_wrist_roll_link'), ('fr_caster_l_wheel_link', 'laser_tilt_mount_link'), ('fr_caster_l_wheel_link', 'r_elbow_flex_link'), ('fr_caster_l_wheel_link', 'r_forearm_roll_link'), ('fr_caster_l_wheel_link', 'r_shoulder_lift_link'), ('fr_caster_l_wheel_link', 'r_shoulder_pan_link'), ('fr_caster_l_wheel_link', 'r_upper_arm_link'), ('fr_caster_l_wheel_link', 'r_upper_arm_roll_link'), ('fr_caster_l_wheel_link', 'sensor_mount_link'), ('fr_caster_l_wheel_link', 'torso_lift_link'), ('fr_caster_r_wheel_link', 'head_pan_link'), ('fr_caster_r_wheel_link', 'head_plate_frame'), ('fr_caster_r_wheel_link', 'head_tilt_link'), ('fr_caster_r_wheel_link', 'l_elbow_flex_link'), ('fr_caster_r_wheel_link', 'l_forearm_link'), ('fr_caster_r_wheel_link', 'l_forearm_roll_link'), ('fr_caster_r_wheel_link', 'l_gripper_motor_accelerometer_link'), ('fr_caster_r_wheel_link', 'l_shoulder_lift_link'), ('fr_caster_r_wheel_link', 'l_shoulder_pan_link'), ('fr_caster_r_wheel_link', 'l_upper_arm_link'), ('fr_caster_r_wheel_link', 'l_upper_arm_roll_link'), ('fr_caster_r_wheel_link', 'l_wrist_flex_link'), ('fr_caster_r_wheel_link', 'l_wrist_roll_link'), ('fr_caster_r_wheel_link', 'laser_tilt_mount_link'), ('fr_caster_r_wheel_link', 'r_elbow_flex_link'), ('fr_caster_r_wheel_link', 'r_forearm_roll_link'), ('fr_caster_r_wheel_link', 'r_shoulder_lift_link'), ('fr_caster_r_wheel_link', 'r_shoulder_pan_link'), ('fr_caster_r_wheel_link', 'r_upper_arm_link'), ('fr_caster_r_wheel_link', 'r_upper_arm_roll_link'), ('fr_caster_r_wheel_link', 'sensor_mount_link'), ('fr_caster_r_wheel_link', 'torso_lift_link'), ('fr_caster_rotation_link', 'head_pan_link'), ('fr_caster_rotation_link', 'head_plate_frame'), ('fr_caster_rotation_link', 'head_tilt_link'), ('fr_caster_rotation_link', 'l_elbow_flex_link'), ('fr_caster_rotation_link', 'l_forearm_roll_link'), ('fr_caster_rotation_link', 'l_gripper_motor_accelerometer_link'), ('fr_caster_rotation_link', 'l_shoulder_lift_link'), ('fr_caster_rotation_link', 'l_shoulder_pan_link'), ('fr_caster_rotation_link', 'l_upper_arm_link'), ('fr_caster_rotation_link', 'l_upper_arm_roll_link'), ('fr_caster_rotation_link', 'laser_tilt_mount_link'), ('fr_caster_rotation_link', 'r_elbow_flex_link'), ('fr_caster_rotation_link', 'r_forearm_roll_link'), ('fr_caster_rotation_link', 'r_shoulder_lift_link'), ('fr_caster_rotation_link', 'r_shoulder_pan_link'), ('fr_caster_rotation_link', 'r_upper_arm_link'), ('fr_caster_rotation_link', 'r_upper_arm_roll_link'), ('fr_caster_rotation_link', 'sensor_mount_link'), ('fr_caster_rotation_link', 'torso_lift_link'), ('head_pan_link', 'l_elbow_flex_link'), ('head_pan_link', 'l_forearm_roll_link'), ('head_pan_link', 'l_gripper_motor_accelerometer_link'), ('head_pan_link', 'l_shoulder_lift_link'), ('head_pan_link', 'l_shoulder_pan_link'), ('head_pan_link', 'l_upper_arm_link'), ('head_pan_link', 'l_upper_arm_roll_link'), ('head_pan_link', 'laser_tilt_mount_link'), ('head_pan_link', 'r_elbow_flex_link'), ('head_pan_link', 'r_forearm_roll_link'), ('head_pan_link', 'r_gripper_motor_accelerometer_link'), ('head_pan_link', 'r_shoulder_lift_link'), ('head_pan_link', 'r_shoulder_pan_link'), ('head_pan_link', 'r_upper_arm_link'), ('head_pan_link', 'r_upper_arm_roll_link'), ('head_pan_link', 'r_wrist_roll_link'), ('head_plate_frame', 'l_elbow_flex_link'), ('head_plate_frame', 'l_forearm_link'), ('head_plate_frame', 'l_forearm_roll_link'), ('head_plate_frame', 'l_gripper_l_finger_link'), ('head_plate_frame', 'l_gripper_l_finger_tip_link'), ('head_plate_frame', 'l_gripper_motor_accelerometer_link'), ('head_plate_frame', 'l_gripper_palm_link'), ('head_plate_frame', 'l_gripper_r_finger_link'), ('head_plate_frame', 'l_gripper_r_finger_tip_link'), ('head_plate_frame', 'l_shoulder_lift_link'), ('head_plate_frame', 'l_shoulder_pan_link'), ('head_plate_frame', 'l_upper_arm_link'), ('head_plate_frame', 'l_upper_arm_roll_link'), ('head_plate_frame', 'l_wrist_flex_link'), ('head_plate_frame', 'l_wrist_roll_link'), ('head_plate_frame', 'laser_tilt_mount_link'), ('head_plate_frame', 'r_elbow_flex_link'), ('head_plate_frame', 'r_forearm_link'), ('head_plate_frame', 'r_forearm_roll_link'), ('head_plate_frame', 'r_gripper_l_finger_link'), ('head_plate_frame', 'r_gripper_l_finger_tip_link'), ('head_plate_frame', 'r_gripper_motor_accelerometer_link'), ('head_plate_frame', 'r_gripper_palm_link'), ('head_plate_frame', 'r_gripper_r_finger_link'), ('head_plate_frame', 'r_gripper_r_finger_tip_link'), ('head_plate_frame', 'r_shoulder_lift_link'), ('head_plate_frame', 'r_shoulder_pan_link'), ('head_plate_frame', 'r_upper_arm_link'), ('head_plate_frame', 'r_upper_arm_roll_link'), ('head_plate_frame', 'r_wrist_flex_link'), ('head_plate_frame', 'r_wrist_roll_link'), ('head_plate_frame', 'torso_lift_link'), ('head_tilt_link', 'l_elbow_flex_link'), ('head_tilt_link', 'l_forearm_roll_link'), ('head_tilt_link', 'l_gripper_motor_accelerometer_link'), ('head_tilt_link', 'l_shoulder_lift_link'), ('head_tilt_link', 'l_shoulder_pan_link'), ('head_tilt_link', 'l_upper_arm_link'), ('head_tilt_link', 'l_upper_arm_roll_link'), ('head_tilt_link', 'laser_tilt_mount_link'), ('head_tilt_link', 'r_elbow_flex_link'), ('head_tilt_link', 'r_forearm_roll_link'), ('head_tilt_link', 'r_gripper_motor_accelerometer_link'), ('head_tilt_link', 'r_shoulder_lift_link'), ('head_tilt_link', 'r_shoulder_pan_link'), ('head_tilt_link', 'r_upper_arm_link'), ('head_tilt_link', 'r_upper_arm_roll_link'), ('head_tilt_link', 'r_wrist_roll_link'), ('head_tilt_link', 'torso_lift_link'), ('l_elbow_flex_link', 'l_forearm_link'), ('l_elbow_flex_link', 'l_gripper_l_finger_link'), ('l_elbow_flex_link', 'l_gripper_l_finger_tip_link'), ('l_elbow_flex_link', 'l_gripper_motor_accelerometer_link'), ('l_elbow_flex_link', 'l_gripper_palm_link'), ('l_elbow_flex_link', 'l_gripper_r_finger_link'), ('l_elbow_flex_link', 'l_gripper_r_finger_tip_link'), ('l_elbow_flex_link', 'l_shoulder_lift_link'), ('l_elbow_flex_link', 'l_shoulder_pan_link'), ('l_elbow_flex_link', 'l_upper_arm_roll_link'), ('l_elbow_flex_link', 'l_wrist_flex_link'), ('l_elbow_flex_link', 'l_wrist_roll_link'), ('l_elbow_flex_link', 'laser_tilt_mount_link'), ('l_elbow_flex_link', 'r_shoulder_lift_link'), ('l_elbow_flex_link', 'r_shoulder_pan_link'), ('l_elbow_flex_link', 'r_upper_arm_roll_link'), ('l_elbow_flex_link', 'sensor_mount_link'), ('l_elbow_flex_link', 'torso_lift_link'), ('l_forearm_link', 'l_gripper_l_finger_link'), ('l_forearm_link', 'l_gripper_l_finger_tip_link'), ('l_forearm_link', 'l_gripper_motor_accelerometer_link'), ('l_forearm_link', 'l_gripper_palm_link'), ('l_forearm_link', 'l_gripper_r_finger_link'), ('l_forearm_link', 'l_gripper_r_finger_tip_link'), ('l_forearm_link', 'l_shoulder_lift_link'), ('l_forearm_link', 'l_upper_arm_link'), ('l_forearm_link', 'l_upper_arm_roll_link'), ('l_forearm_link', 'l_wrist_roll_link'), ('l_forearm_link', 'sensor_mount_link'), ('l_forearm_roll_link', 'l_gripper_l_finger_link'), ('l_forearm_roll_link', 'l_gripper_l_finger_tip_link'), ('l_forearm_roll_link', 'l_gripper_motor_accelerometer_link'), ('l_forearm_roll_link', 'l_gripper_palm_link'), ('l_forearm_roll_link', 'l_gripper_r_finger_link'), ('l_forearm_roll_link', 'l_gripper_r_finger_tip_link'), ('l_forearm_roll_link', 'l_shoulder_lift_link'), ('l_forearm_roll_link', 'l_shoulder_pan_link'), ('l_forearm_roll_link', 'l_upper_arm_link'), ('l_forearm_roll_link', 'l_upper_arm_roll_link'), ('l_forearm_roll_link', 'l_wrist_flex_link'), ('l_forearm_roll_link', 'l_wrist_roll_link'), ('l_forearm_roll_link', 'laser_tilt_mount_link'), ('l_forearm_roll_link', 'r_shoulder_lift_link'), ('l_forearm_roll_link', 'r_shoulder_pan_link'), ('l_forearm_roll_link', 'r_upper_arm_roll_link'), ('l_forearm_roll_link', 'sensor_mount_link'), ('l_forearm_roll_link', 'torso_lift_link'), ('l_gripper_l_finger_link', 'l_gripper_motor_accelerometer_link'), ('l_gripper_l_finger_link', 'l_gripper_r_finger_link'), ('l_gripper_l_finger_link', 'l_gripper_r_finger_tip_link'), ('l_gripper_l_finger_link', 'l_shoulder_lift_link'), ('l_gripper_l_finger_link', 'l_upper_arm_link'), ('l_gripper_l_finger_link', 'l_upper_arm_roll_link'), ('l_gripper_l_finger_link', 'l_wrist_flex_link'), ('l_gripper_l_finger_link', 'l_wrist_roll_link'), ('l_gripper_l_finger_link', 'sensor_mount_link'), ('l_gripper_l_finger_tip_link', 'l_gripper_motor_accelerometer_link'), ('l_gripper_l_finger_tip_link', 'l_gripper_palm_link'), ('l_gripper_l_finger_tip_link', 'l_gripper_r_finger_link'), ('l_gripper_l_finger_tip_link', 'l_shoulder_lift_link'), ('l_gripper_l_finger_tip_link', 'l_upper_arm_link'), ('l_gripper_l_finger_tip_link', 'l_upper_arm_roll_link'), ('l_gripper_l_finger_tip_link', 'l_wrist_flex_link'), ('l_gripper_l_finger_tip_link', 'l_wrist_roll_link'), ('l_gripper_l_finger_tip_link', 'sensor_mount_link'), ('l_gripper_motor_accelerometer_link', 'l_gripper_r_finger_link'), ('l_gripper_motor_accelerometer_link', 'l_gripper_r_finger_tip_link'), ('l_gripper_motor_accelerometer_link', 'l_shoulder_lift_link'), ('l_gripper_motor_accelerometer_link', 'l_upper_arm_link'), ('l_gripper_motor_accelerometer_link', 'l_upper_arm_roll_link'), ('l_gripper_motor_accelerometer_link', 'l_wrist_flex_link'), ('l_gripper_motor_accelerometer_link', 'l_wrist_roll_link'), ('l_gripper_motor_accelerometer_link', 'laser_tilt_mount_link'), ('l_gripper_motor_accelerometer_link', 'r_gripper_l_finger_tip_link'), ('l_gripper_motor_accelerometer_link', 'r_gripper_motor_accelerometer_link'), ('l_gripper_motor_accelerometer_link', 'r_gripper_r_finger_tip_link'), ('l_gripper_motor_accelerometer_link', 'r_wrist_flex_link'), ('l_gripper_motor_accelerometer_link', 'r_wrist_roll_link'), ('l_gripper_motor_accelerometer_link', 'sensor_mount_link'), ('l_gripper_palm_link', 'l_gripper_r_finger_tip_link'), ('l_gripper_palm_link', 'l_shoulder_lift_link'), ('l_gripper_palm_link', 'l_upper_arm_link'), ('l_gripper_palm_link', 'l_upper_arm_roll_link'), ('l_gripper_palm_link', 'l_wrist_flex_link'), ('l_gripper_palm_link', 'sensor_mount_link'), ('l_gripper_r_finger_link', 'l_shoulder_lift_link'), ('l_gripper_r_finger_link', 'l_upper_arm_link'), ('l_gripper_r_finger_link', 'l_upper_arm_roll_link'), ('l_gripper_r_finger_link', 'l_wrist_flex_link'), ('l_gripper_r_finger_link', 'l_wrist_roll_link'), ('l_gripper_r_finger_link', 'sensor_mount_link'), ('l_gripper_r_finger_tip_link', 'l_shoulder_lift_link'), ('l_gripper_r_finger_tip_link', 'l_upper_arm_link'), ('l_gripper_r_finger_tip_link', 'l_upper_arm_roll_link'), ('l_gripper_r_finger_tip_link', 'l_wrist_flex_link'), ('l_gripper_r_finger_tip_link', 'l_wrist_roll_link'), ('l_gripper_r_finger_tip_link', 'r_gripper_motor_accelerometer_link'), ('l_gripper_r_finger_tip_link', 'sensor_mount_link'), ('l_shoulder_lift_link', 'l_upper_arm_link'), ('l_shoulder_lift_link', 'l_wrist_flex_link'), ('l_shoulder_lift_link', 'l_wrist_roll_link'), ('l_shoulder_lift_link', 'laser_tilt_mount_link'), ('l_shoulder_lift_link', 'r_elbow_flex_link'), ('l_shoulder_lift_link', 'r_forearm_roll_link'), ('l_shoulder_lift_link', 'r_shoulder_lift_link'), ('l_shoulder_lift_link', 'r_upper_arm_link'), ('l_shoulder_lift_link', 'r_upper_arm_roll_link'), ('l_shoulder_lift_link', 'sensor_mount_link'), ('l_shoulder_lift_link', 'torso_lift_link'), ('l_shoulder_pan_link', 'l_upper_arm_roll_link'), ('l_shoulder_pan_link', 'laser_tilt_mount_link'), ('l_shoulder_pan_link', 'r_elbow_flex_link'), ('l_shoulder_pan_link', 'r_forearm_roll_link'), ('l_shoulder_pan_link', 'sensor_mount_link'), ('l_upper_arm_link', 'l_wrist_flex_link'), ('l_upper_arm_link', 'l_wrist_roll_link'), ('l_upper_arm_link', 'laser_tilt_mount_link'), ('l_upper_arm_link', 'r_shoulder_lift_link'), ('l_upper_arm_link', 'sensor_mount_link'), ('l_upper_arm_link', 'torso_lift_link'), ('l_upper_arm_roll_link', 'l_wrist_flex_link'), ('l_upper_arm_roll_link', 'l_wrist_roll_link'), ('l_upper_arm_roll_link', 'laser_tilt_mount_link'), ('l_upper_arm_roll_link', 'r_elbow_flex_link'), ('l_upper_arm_roll_link', 'r_forearm_roll_link'), ('l_upper_arm_roll_link', 'r_gripper_motor_accelerometer_link'), ('l_upper_arm_roll_link', 'r_shoulder_lift_link'), ('l_upper_arm_roll_link', 'r_upper_arm_link'), ('l_upper_arm_roll_link', 'r_upper_arm_roll_link'), ('l_upper_arm_roll_link', 'sensor_mount_link'), ('l_upper_arm_roll_link', 'torso_lift_link'), ('l_wrist_flex_link', 'sensor_mount_link'), ('l_wrist_roll_link', 'laser_tilt_mount_link'), ('l_wrist_roll_link', 'sensor_mount_link'), ('laser_tilt_mount_link', 'r_elbow_flex_link'), ('laser_tilt_mount_link', 'r_forearm_roll_link'), ('laser_tilt_mount_link', 'r_gripper_motor_accelerometer_link'), ('laser_tilt_mount_link', 'r_shoulder_lift_link'), ('laser_tilt_mount_link', 'r_shoulder_pan_link'), ('laser_tilt_mount_link', 'r_upper_arm_link'), ('laser_tilt_mount_link', 'r_upper_arm_roll_link'), ('laser_tilt_mount_link', 'r_wrist_roll_link'), ('laser_tilt_mount_link', 'sensor_mount_link'), ('r_elbow_flex_link', 'r_forearm_link'), ('r_elbow_flex_link', 'r_gripper_l_finger_link'), ('r_elbow_flex_link', 'r_gripper_l_finger_tip_link'), ('r_elbow_flex_link', 'r_gripper_motor_accelerometer_link'), ('r_elbow_flex_link', 'r_gripper_palm_link'), ('r_elbow_flex_link', 'r_gripper_r_finger_link'), ('r_elbow_flex_link', 'r_gripper_r_finger_tip_link'), ('r_elbow_flex_link', 'r_shoulder_lift_link'), ('r_elbow_flex_link', 'r_shoulder_pan_link'), ('r_elbow_flex_link', 'r_upper_arm_roll_link'), ('r_elbow_flex_link', 'r_wrist_flex_link'), ('r_elbow_flex_link', 'r_wrist_roll_link'), ('r_elbow_flex_link', 'sensor_mount_link'), ('r_elbow_flex_link', 'torso_lift_link'), ('r_forearm_link', 'r_gripper_l_finger_link'), ('r_forearm_link', 'r_gripper_l_finger_tip_link'), ('r_forearm_link', 'r_gripper_motor_accelerometer_link'), ('r_forearm_link', 'r_gripper_palm_link'), ('r_forearm_link', 'r_gripper_r_finger_link'), ('r_forearm_link', 'r_gripper_r_finger_tip_link'), ('r_forearm_link', 'r_shoulder_lift_link'), ('r_forearm_link', 'r_upper_arm_link'), ('r_forearm_link', 'r_upper_arm_roll_link'), ('r_forearm_link', 'r_wrist_roll_link'), ('r_forearm_link', 'sensor_mount_link'), ('r_forearm_roll_link', 'r_gripper_l_finger_link'), ('r_forearm_roll_link', 'r_gripper_l_finger_tip_link'), ('r_forearm_roll_link', 'r_gripper_motor_accelerometer_link'), ('r_forearm_roll_link', 'r_gripper_palm_link'), ('r_forearm_roll_link', 'r_gripper_r_finger_link'), ('r_forearm_roll_link', 'r_gripper_r_finger_tip_link'), ('r_forearm_roll_link', 'r_shoulder_lift_link'), ('r_forearm_roll_link', 'r_shoulder_pan_link'), ('r_forearm_roll_link', 'r_upper_arm_link'), ('r_forearm_roll_link', 'r_upper_arm_roll_link'), ('r_forearm_roll_link', 'r_wrist_flex_link'), ('r_forearm_roll_link', 'r_wrist_roll_link'), ('r_forearm_roll_link', 'sensor_mount_link'), ('r_forearm_roll_link', 'torso_lift_link'), ('r_gripper_l_finger_link', 'r_gripper_motor_accelerometer_link'), ('r_gripper_l_finger_link', 'r_gripper_r_finger_link'), ('r_gripper_l_finger_link', 'r_gripper_r_finger_tip_link'), ('r_gripper_l_finger_link', 'r_shoulder_lift_link'), ('r_gripper_l_finger_link', 'r_upper_arm_link'), ('r_gripper_l_finger_link', 'r_upper_arm_roll_link'), ('r_gripper_l_finger_link', 'r_wrist_flex_link'), ('r_gripper_l_finger_link', 'r_wrist_roll_link'), ('r_gripper_l_finger_link', 'sensor_mount_link'), ('r_gripper_l_finger_tip_link', 'r_gripper_motor_accelerometer_link'), ('r_gripper_l_finger_tip_link', 'r_gripper_palm_link'), ('r_gripper_l_finger_tip_link', 'r_gripper_r_finger_link'), ('r_gripper_l_finger_tip_link', 'r_shoulder_lift_link'), ('r_gripper_l_finger_tip_link', 'r_upper_arm_link'), ('r_gripper_l_finger_tip_link', 'r_upper_arm_roll_link'), ('r_gripper_l_finger_tip_link', 'r_wrist_flex_link'), ('r_gripper_l_finger_tip_link', 'r_wrist_roll_link'), ('r_gripper_l_finger_tip_link', 'sensor_mount_link'), ('r_gripper_motor_accelerometer_link', 'r_gripper_r_finger_link'), ('r_gripper_motor_accelerometer_link', 'r_gripper_r_finger_tip_link'), ('r_gripper_motor_accelerometer_link', 'r_shoulder_lift_link'), ('r_gripper_motor_accelerometer_link', 'r_upper_arm_link'), ('r_gripper_motor_accelerometer_link', 'r_upper_arm_roll_link'), ('r_gripper_motor_accelerometer_link', 'r_wrist_flex_link'), ('r_gripper_motor_accelerometer_link', 'r_wrist_roll_link'), ('r_gripper_motor_accelerometer_link', 'sensor_mount_link'), ('r_gripper_palm_link', 'r_gripper_r_finger_tip_link'), ('r_gripper_palm_link', 'r_shoulder_lift_link'), ('r_gripper_palm_link', 'r_upper_arm_link'), ('r_gripper_palm_link', 'r_upper_arm_roll_link'), ('r_gripper_palm_link', 'r_wrist_flex_link'), ('r_gripper_palm_link', 'sensor_mount_link'), ('r_gripper_r_finger_link', 'r_shoulder_lift_link'), ('r_gripper_r_finger_link', 'r_upper_arm_link'), ('r_gripper_r_finger_link', 'r_upper_arm_roll_link'), ('r_gripper_r_finger_link', 'r_wrist_flex_link'), ('r_gripper_r_finger_link', 'r_wrist_roll_link'), ('r_gripper_r_finger_link', 'sensor_mount_link'), ('r_gripper_r_finger_tip_link', 'r_shoulder_lift_link'), ('r_gripper_r_finger_tip_link', 'r_upper_arm_link'), ('r_gripper_r_finger_tip_link', 'r_upper_arm_roll_link'), ('r_gripper_r_finger_tip_link', 'r_wrist_flex_link'), ('r_gripper_r_finger_tip_link', 'r_wrist_roll_link'), ('r_gripper_r_finger_tip_link', 'sensor_mount_link'), ('r_shoulder_lift_link', 'r_upper_arm_link'), ('r_shoulder_lift_link', 'r_wrist_flex_link'), ('r_shoulder_lift_link', 'r_wrist_roll_link'), ('r_shoulder_lift_link', 'sensor_mount_link'), ('r_shoulder_lift_link', 'torso_lift_link'), ('r_shoulder_pan_link', 'r_upper_arm_roll_link'), ('r_shoulder_pan_link', 'sensor_mount_link'), ('r_upper_arm_link', 'r_wrist_flex_link'), ('r_upper_arm_link', 'r_wrist_roll_link'), ('r_upper_arm_link', 'sensor_mount_link'), ('r_upper_arm_link', 'torso_lift_link'), ('r_upper_arm_roll_link', 'r_wrist_flex_link'), ('r_upper_arm_roll_link', 'r_wrist_roll_link'), ('r_upper_arm_roll_link', 'sensor_mount_link'), ('r_upper_arm_roll_link', 'torso_lift_link'), ('r_wrist_flex_link', 'sensor_mount_link'), ('r_wrist_roll_link', 'sensor_mount_link'), ('sensor_mount_link', 'torso_lift_link') ] + [ ('l_upper_arm_link', 'l_shoulder_pan_link'), ('r_upper_arm_link', 'r_shoulder_pan_link'), ]
51,193
Python
91.575045
120
0.532104