APIs

Robotics Academy is a web-based learning platform for robotics that abstracts other ROS operations. It accomplishes this by utilising APIs that handle all of the work behind the scenes. There are three types of APIs defined: GUI, HAL, and ENV. The details of these APIs are covered in the following sections.

HAL

HAL(Hardware Abstraction Layer) APIs are used to interact with robot which means one can send commands to different parts of robot using these APIs. Pick and Place exercise requires the following HAL APIs:

  • move_pose_arm(pose_goal) : Command the robot with Pose message to make its end effector frame move to the desired pose with inverse kinematics.
  • move_joint_arm(joint_0,joint_1,joint_2,joint_3,joint_4,joint_5) : Command the robot joints to move to desired joints value
  • move_joint_hand(joint_value) : Command the gripper joint to move to desired joint value.
  • back_to_home() : Command the robot arm and gripper to move back to the home pose.

ENV

ENV APIs are used to get the information about the objects present in the world/enviornment. These APIs also containes the helper functions that are useful to complete the exercise.

  • get_object_list() : Return the name list of all objects.
  • get_object_pose(object_name) : Return the pose of the object.
  • get_object_info(object_name) : Return the pose, height, width, length, shape, color of the object in order.
  • get_target_list() : Return the name list of all targets.
  • get_target_position(target_name) : Return the position of target where we are going to place the objects.
  • pose2msg(roll, pitch, yaw, x, y, z) : Convert pose to Pose message. The unit of roll, pitch, yaw is radian.
  • msg2pose(pose) : Convert Pose message to pose, return roll, pitch, yaw, x, y, z in order. The unit of roll, pitch, yaw is radian.

Since in the process of connecting the exercises, the manager.py checks through these APIs, so I thought of creating them in the begining of this week. Also, this exercise doesn’t need GUI so there is no need of GUI APIs but GUI.py contains some functions related to threads that I’m still not sure about and they could be contributing to the connection of exercises. As a result, I’ve temporarily replaced GUI.py with ENV.py.

Gazebo path errors

Following the creation of the APIs, I moved on to connecting the exercise to the server. I tried to connect after making some changes to exercise.py, but I came across a very unpleasant problem. The compiller wasn’t able to identify “pick_place” key in the instructions.json.

gazebo_path = self.GAZEBO_RESOURCE_PATH + self.instructions[exercise]["gazebo_path"] + ";"
KeyError: 'pick_place'
_XSERVTransmkdir: ERROR: Cannot create /tmp/.X11-unix
_XSERVTransSocketUNIXCreateListener: mkdir(/tmp/.X11-unix) failed, errno = 17
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for unix

It appears to be very simple problem where one just needs to add the paths in instructions.json but the problem was that I added the paths right from the start.

I was finally able to figure out the problem after a lot of testing. Actually, the compiler wasn’t compiling the code I edited; instead, it made a copy of manager.py and instructions.json in the root directory, which it then executed. The changes in my local repository didn’t effect other files because I mounted it with the RoboticsAcademy repository in the container. So, in the end, I updated the root directory’s instructions.json.

RADI 2.3 or 2.4.2

After resolving some more XML errors, I ran into another major error. ROS wasn’t able to find the Industrial Robots packages cloned in /opt/jderobot along with Custom Robots directory. I tried changing the ROS PACKAGE PATH variable, but it didn’t help. I decided to put these packages in a catkin workspace after browsing the internet for a bit. However, there was no catkin workspace in RADI2.3, but there is in RADI2.4. So I had the option of creating a catkin workspace or upgrading to RADI2.4.2. I decided to use RADI2.4.2 after consulting with my mentor. I successfully moved on to RADI2.4.2 after making few adjustments in Dockerfile2.4.2 and manager.py.

Finally, up until debugging level 4, the exercise was able to connect (simulation started and code and gui websockets opened). The gazebo was operational, and all of the objects, including the robot, were properly spawned.

Although the gazebo is working, there are still some warnings and errors which are needed to be resolved.

[Err] [ModelDatabase.cc:390] Unable to parse model.config for model[http://gazebosim.org/models/bin_4_dropping_task]
Failed to load plugin libroboticsgroup_gazebo_mimic_joint_plugin.so: libroboticsgroup_gazebo_mimic_joint_plugin.so: cannot open shared object file: No such file or directory

In addition, we are still a step away from fully connecting our exercise. The connection with code websocket is still not working, and the shell displays the following error:

Traceback (most recent call last):
File "/RoboticsAcademy/exercises/pick_place/web-template/exercise.py", line 351, in <module>
    server.run_server()
File "/RoboticsAcademy/exercises/pick_place/web-template/exercise.py", line 341, in run_server
    self.server = WebsocketServer(port=1905, host=self.host)
File "/usr/local/lib/python2.7/dist-packages/websocket_server/websocket_server.py", line 97, in __init__
    TCPServer.__init__(self, (host, port), WebSocketHandler)
File "/usr/lib/python2.7/SocketServer.py", line 420, in __init__
    self.server_bind()
File "/usr/lib/python2.7/SocketServer.py", line 434, in server_bind
    self.socket.bind(self.server_address)
File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use

It’s evident that ws code has several issues, and I’ll be fixing them and working on the widget/Rviz in the coming week.