Repository: stepjam/RLBench
Issue: Sawyer arm - tip location problematic
Root cause: Architectural Constraint

Hi,

I have opened this same issue in PyRep (https://github.com/stepjam/PyRep/issues/214). Feel free to close whichever is in the less appropriate place!

Hi,

TL;DR: Sawyer 'tip' in middle of wrist, causes problems. 

I first posted this problem on the RLBench discord channel a few months ago and was advised to make an RLBench issue.

In short: I get unexpected behaviour using the Sawyer robot in RLBench, which might stem from the PyRep model. Below are gifs of a corner reaching task, executed on the Panda and Sawyer. Though the waypoint target's Euler is (0,0,0), and though this is clearly reflected in the Panda solution, the Sawyer arm performs a strange rotation. 
![sawyer_reach_corner_1](https://user-images.githubusercontent.com/28831431/96375891-b9243080-1173-11eb-91d7-d96eefd4d3dc.gif)
![panda_reach_corner_00](https://user-images.githubusercontent.com/28831431/96377024-600bcb00-117a-11eb-86f2-6f85c16ad2c5.gif)

I believe the explanation is that this is for collision avoidance (and it's possible that I'm not using the Euler restriction correctly, hence why a solution can be found at all). The reason collision avoidance is needed, I believe, is that the 'tip' of the Sawyer robot in PyRep is not defined, as it is for the Panda, as the space between the gripper fingers, but instead is a point in the middle of the wrist. The next 3 images show, respectively: 
1st: the Panda 'tip'
2nd: the Sawyer tip seen from a distance (though selected in CoppeliaSim, you can't see anything)
3rd: a zoom-in on the Sawyer tip from the same viewpoint - it is found within the wrist, and appears to have an orientation 90º to that of the Panda.

<img width="500" alt="panda_tip" src="https://user-images.githubusercontent.com/28831431/96376862-4b7b0300-1179-11eb-9a11-17e6c8118638.png">
<img width="500" alt="sawyer_tip" src="https://user-images.githubusercontent.com/28831431/96376859-4918a900-1179-11eb-9ab4-093b13657efb.png">
<img width="500" alt="sawyer_tip_zoomed" src="https://user-images.githubusercontent.com/28831431/96376857-47e77c00-1179-11eb-8d0c-aaae3c01bec4.png">

In terms of reproducibility, the gif is from a custom task, but you can see that an error occurs when using the sawyer, but not the panda, in a simple setting with the following (apologies for RLBench dependency):

~~~python
from rlbench.environment import Environment
from rlbench.action_modes import ActionMode, ArmActionMode
from rlbench.tasks import ReachTarget
import numpy as np
action_mode = ActionMode(ArmActionMode.ABS_JOINT_VELOCITY)
env = Environment(action_mode, robot_configuration='sawyer')
env.launch()
task = env.get_task(ReachTarget)
demo = task.get_demos(1, live_demos=True)`
~~~

Running with `env = Environment(action_mode)` in place of `env = Environment(action_mode, robot_configuration='sawyer')` runs without incident and collects a Panda arm demo. With the Sawyer, I get the following:
~~~
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/me/Code/RLBench/rlbench/task_environment.py", line 352, in get_demos
    amount, callable_each_step, max_attempts)
  File "/home/me/Code/RLBench/rlbench/task_environment.py", line 365, in _get_live_demos
    self.reset()
  File "/home/me/Code/RLBench/rlbench/task_environment.py", line 87, in reset
    % self._task.get_name()) from e
rlbench.task_environment.TaskEnvironmentError: Could not place the task reach_target in the scene. This should not happen, please raise an issues on this task.
~~~

Thanks for the issue. This is a RLBench issue so I'll close the other PyRep one. I'll try and get to this before the end of the week. Should be an easy fix :)