Use Ned’s TCP server

Ned is permanently running a TCP Server to acquire requests. This server is built on top of the Ned Python ROS Wrapper.

It offers a simple way for developers to create programs for robot to control them via remote communication on a computer, on a mobile or any device with network facilities.

Programs can communicate through network TCP with the robots in any language available.

Connection

To access the server, you will have to use to robot’s IP adress and communicate via the port 40001.

Communication

Only one client can communicate with the server (reconnection effective but no multi clients).

The server answer only after the command is done, so it cannot deal with multiple commands at the same time.

Packet convention

General format

For easier usage and easier debugging, the communication is based on JSON format.

Every package have this following shape: <json_packet_size>{<json_content>}<payload>.

The JSON packet size is an unsigned short coded on 2 bytes.

The JSON contains command’s name & params.

Payload contains heavy data like an image.

Request

Format - Request

As no function request a payload in input, requests have the following.

Format: <json_packet_size>{'param_list': [<param_1>, <param_2>, ....], 'command': <command_str>}

Examples - Request

Calibrate auto: {'param_list': ['AUTO'], 'command': 'CALIBRATE'}

Move joints: {'param_list': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'command': 'MOVE_JOINTS'}

Answer

Format - Answer

Firstly, answers indicate to the user if its command has been well executed. This is indicated in the JSON by the parameter “status”.

A successful answer will have the format:

{'status': 'OK', 'list_ret_param': [<param_1>, <param_2>, ....], 'payload_size': <payload_size_int>, 'command': <command_str>}<payload_str>

An unsuccessful answer will have the format: {'status': 'KO', 'message': <message_str>}

Examples - Answer

Calibrate Auto: {'status': 'OK', 'list_ret_param': [], 'payload_size': 0, 'command': 'CALIBRATE'}

Get Pose: {'status': 'OK', 'list_ret_param': [0.2, 0.15, 0.35, 0.5, -0.6, 0.1], 'payload_size': 0, 'command': 'GET_POSE'}

Commands enum for TCP server

class CommandEnum[source]

Enumeration of all commands used

CALIBRATE = 0
SET_LEARNING_MODE = 1
GET_LEARNING_MODE = 2
SET_ARM_MAX_VELOCITY = 3
SET_JOG_CONTROL = 4
GET_JOINTS = 10
GET_POSE = 11
GET_POSE_QUAT = 12
MOVE_JOINTS = 20
MOVE_POSE = 21
SHIFT_POSE = 22
MOVE_LINEAR_POSE = 23
SHIFT_LINEAR_POSE = 24
JOG_JOINTS = 25
JOG_POSE = 26
FORWARD_KINEMATICS = 27
INVERSE_KINEMATICS = 28
GET_POSE_SAVED = 50
SAVE_POSE = 51
DELETE_POSE = 52
GET_SAVED_POSE_LIST = 53
PICK_FROM_POSE = 60
PLACE_FROM_POSE = 61
PICK_AND_PLACE = 62
GET_TRAJECTORY_SAVED = 80
EXECUTE_TRAJECTORY_FROM_POSES = 81
EXECUTE_TRAJECTORY_SAVED = 82
SAVE_TRAJECTORY = 83
DELETE_TRAJECTORY = 84
GET_SAVED_TRAJECTORY_LIST = 85
UPDATE_TOOL = 120
OPEN_GRIPPER = 121
CLOSE_GRIPPER = 122
PULL_AIR_VACUUM_PUMP = 123
PUSH_AIR_VACUUM_PUMP = 124
SETUP_ELECTROMAGNET = 125
ACTIVATE_ELECTROMAGNET = 126
DEACTIVATE_ELECTROMAGNET = 127
GET_CURRENT_TOOL_ID = 128
GRASP_WITH_TOOL = 129
RELEASE_WITH_TOOL = 130
SET_PIN_MODE = 150
DIGITAL_WRITE = 151
DIGITAL_READ = 152
GET_DIGITAL_IO_STATE = 153
GET_HARDWARE_STATUS = 154
SET_CONVEYOR = 180
UNSET_CONVEYOR = 181
CONTROL_CONVEYOR = 182
GET_CONNECTED_CONVEYORS_ID = 183
GET_IMAGE_COMPRESSED = 200
GET_TARGET_POSE_FROM_REL = 201
GET_TARGET_POSE_FROM_CAM = 202
VISION_PICK = 203
MOVE_TO_OBJECT = 205
DETECT_OBJECT = 204
GET_CAMERA_INTRINSICS = 210
SAVE_WORKSPACE_FROM_POSES = 220
SAVE_WORKSPACE_FROM_POINTS = 221
DELETE_WORKSPACE = 222
GET_WORKSPACE_RATIO = 223
GET_WORKSPACE_LIST = 224