5.1.1.1. node_ur5_1_pick

ROS Node for UR5_1 arm to pick packages from shelf and place them on conveyor belt.

At first, the colour of the packages are detected by importing the qr node. Then the inventory sheet is updated by sending a goal to the action server. After that whenever a new order is placed on the MQTT topic “/eyrc/vb/isPicuTP/orders”, it is appended to a local list. This list is sorted according to the priority of the orders and then the order at the top of list is processed and picked up from the shelf and placed on conveyor belt. The details of the dispatched order are than updated in the “DispatchedOrder” sheet by sending a goal to the action server.

class node_ur5_1_pick.DispatchedPkg[source]

Class to store name and colour of the dispatched package

set_colour(colour)[source]

Set colour of the dispatched package

Parameters:colour (str) – colour of the package
Returns:None
set_name(name)[source]

Set name of the dispatched package

Parameters:name (str) – name of the package
Returns:None
class node_ur5_1_pick.RosIotBridgeActionClient[source]

Action Client to act as a bridge between ROS Nodes and IOT to update google spreadsheets

on_transition(goal_handle)[source]

This function will be called when there is change of state in the Action Client State Machine

Parameters:goal_handle – unique id of goal
Returns:None
send_goal(arg_protocol, arg_mode, arg_topic, arg_message)[source]

This function is used to send Goals to Action Server

Parameters:
  • arg_protocol (str) – IoT protocol to follow (HTTP, MQTT, etc.)
  • arg_mode (str) – Mode whether to publish or subscribe
  • arg_topic (str) – Topic to subscribe or publish to
  • arg_message (str) – Message to push or publish
Returns:

goal handle

class node_ur5_1_pick.ShelfCamera[source]

Store information regarding colour of packages on shelf as recognised by the 2D Camera

get_pkg_colour(row, column)[source]

Return colour of package present on specific row and column

Parameters:
  • row (int) – row of package
  • column (int) – column of package
Returns:

list of colour of all the packages present on shelf

Return type:

list

get_pkg_colour_list()[source]

Return list of colour of all the packages present on the shelf

Returns:List of colour of all the packages present on the shelf
Return type:list
print_colours()[source]

Print colour of all the packages present on the shelf with their name(row and column).

Returns:None
sub_callback(camera_image)[source]

Update colour of packages in the local list identified by the 2D Camera

Parameters:camera_image (Camera1Image) – information of all the packages seen by the camera
Returns:None
class node_ur5_1_pick.Ur5Moveit(arg_robot_name)[source]

Initialize necessary objects to operate a UR5 arm

Initialize trajectory publisher, execute client, planning scene interface, move group commander, vacuum gripper service and other necessary things for proper interface of Ur5 arm with Gazebo, MoveIt! and RViz

Parameters:arg_robot_name (str) – Name of Ur5 arm to control
Example:

ur5_1 = Ur5Moveit(‘ur5_1’)

attach_box_in_gazebo()[source]

Activate vacuum gripper of arm in gazebo

Returns:None
detach_box_in_gazebo()[source]

Deactivate vacuum gripper of arm in gazebo

Returns:None
hard_play_saved_trajectory(trajectory, arg_max_attempts)[source]

Try playing a trajectory again and again until success or max attempts exhausted

Parameters:
  • trajectory (JointTrajectory) – Trajectory to be played
  • arg_max_attempts (int) – Max number of attempts to try again in case of failure
Returns:

success flag

Return type:

bool

hard_set_joint_angles(arg_list_joint_angles, arg_max_attempts)[source]

Try to set the joint angles again and again until success or max attempts exhausted

Parameters:
  • arg_list_joint_angles (list) – list of goal joint angles of UR5 arm in radians
  • arg_max_attempts (int) – maximum number of attempts to try
Returns:

None

play_saved_trajectory(trajectory)[source]

Play a trajectory which was saved before

Parameters:trajectory (JointTrajectory) – Trajectory to be played
Returns:success flag
Return type:bool
set_joint_angles(arg_list_joint_angles)[source]

Set joint angles of arm to pre defined joint angles

Parameters:arg_list_joint_angles (list) – list of goal joint angles of UR5 arm in radians
Returns:Success flag
Return type:bool
node_ur5_1_pick.find_correct_pkg_on_shelf(camera, current_order, at_waiting_pose)[source]

Function to find the correct package to be picked up from the shelf

Parameters:
  • camera (Object of class ShelfCamera which stores all info related to packages on shelf) – object storing information packages present on the shelf
  • current_order (dict) – Details of order to find on the shelf
  • at_waiting_pose (bool) – If UR5#1 arm is at waiting pose or not
Returns:

row and column of the required package

Return type:

int, int

node_ur5_1_pick.go_to_home_position(ur5_1)[source]

Move UR5#1 arm to its home position

Parameters:ur5_1 (Object of class Ur5Moveit) – Object of class Ur5Moveit to control UR5#1 arm
Returns:None
node_ur5_1_pick.go_to_package(ur5_1, saved_trajectories, row, column)[source]

Move the UR5#1 arm to the package to pick it up

Parameters:
  • ur5_1 (Object of class Ur5Moveit) – Object of class Ur5Moveit to control UR5#1 arm
  • saved_trajectories (dict) – Dictionary of all the saved trajectories already loaded
  • row (int) – Row of the package to pick up
  • column (int) – Column of the package to pick up
node_ur5_1_pick.load_saved_trajectories(saved_trajectories)[source]

Load all the saved trajectories and store them in a dictionary

Parameters:saved_trajectories (dict) – Dictionary to store the loaded trajectories
Returns:None
node_ur5_1_pick.main()[source]

Main node to control UR5_1 arm.

This function is called to start the pick and place operation of UR5_1 arm. :return: None

node_ur5_1_pick.new_order_callback(msg, orders_list)[source]

Callback function called whenever a new order is placed

Parameters:
  • msg (json object) – Order details
  • orders_list (list) – List of the current active orders
Returns:

None

node_ur5_1_pick.start_conveyor_belt(power)[source]

Function to start the conveyor belt at a certain power

Parameters:power (int) – power of the belt to be set
Returns:success flag
Return type:bool
node_ur5_1_pick.stop_conveyor_belt()[source]

Function to stop the conveyor belt

Returns:Success flag
Return type:bool
node_ur5_1_pick.update_inventory(pkg_colour_list, action_client)[source]

Update inventory spreadsheet

Parameters:
  • pkg_colour_list (list) – List of colour of all the packages present on the shelf
  • action_client (Object of class RosIotBridgeActionClient) – action client to send goals to push data on spreadsheet
Returns:

None

node_ur5_1_pick.update_orders_dispatched_sheet(order, action_client)[source]

Update dispatched orders spreadsheet

Parameters:
  • order (dict) – Information of the order dispatched
  • action_client (Object of class RosIotBridgeActionClient) – action client to send goal to push data on spreadsheet
Returns:

None

node_ur5_1_pick.waiting_position_benefit(camera)[source]

This function is called to check if there will be any benefit in picking up package quickly from the shelf if we go to waiting position or not. It checks whether there are 3 types of packages(red, yellow, and green) are available in the shelf area covered by the waiting position or not.

Parameters:camera (Object of class ShelfCamera which stores all info related to packages on shelf) – object storing information packages present on the shelf
Returns:Benefit or not to go and wait at home position
Return type:bool