ElephantROBOTICS
Python API for RoboFlow

1. Overview

Elephant provides python API to control the robot from remote, we use tcp protocol tocommunicate between the client and the robot, so before you can use our API, you need toinitialize a client like this first:
elephant_client = ElephantRobot(‘192.168.1.100’, 5001)
where ‘192.168.1.100’ is the ip of robot controller, and 5001 is the listening port;then you need to start the client by call:
res = elephant_client.start_client()
if res is not empty, it means failed to start client, you can got the fail message in res.
If success, then you can call our API, all available APIs are introduced as bellow.

2. API Instruction

2.1 array get_angles()This api is use to get current angles of the robot;
example: angles = elephant_client.get_angles()the return value is an array, like this: [0.174058, 0.520382, -0.07874, 0.092855, 0.0,0.030356]. If any error occurred, InvalidCoords()(defined as [-1.0, -2.0, -3.0, -4.0, -1.0, -1.0])
will be returned.

2.2 array get_coords()

This api is use to get current coordinate of the robot;
example: coords = elephant_client.get_coords ()the return value is an array, like this: [0.174058, 0.520382, -0.07874, 0.092855, 0.0,0.030356]. If any error occurred, InvalidCoords()(defined as [-1.0, -2.0, -3.0, -4.0, -1.0, -1.0])
will be returned.

2.3. double get_speed()

This api is use to get current speed of the robot;
example: speed = elephant_client.get_speed ()the unit of speed is mm/min

2.4. bool power_on()

This api is use to power on the robot;
example: elephant_client.power_on()

2.5. bool power_off()

This api is use to power off the robot;
example: elephant_client.power_off()

2.6. bool check_running()

This api is use to check if the robot finish the last command, if still excuting(not finish),true will be returned, otherwise false will be returned.
Example: bool running = elephant_client.check_running()

2.7. bool state_check()

This api is use to check if the robot is in normal state, if in normal state, true will bereturned, otherwise false will be returned.
Example: bool ok = elephant_client.state_running()

2.8. int program_open(string program_file_path)

This api is use to open a G Code formated text file(the full path is program_file_path).

Example: int ok = elephant_client.program_open(‘a.txt’)0 will be return if success, the other means fail.

2.9. int program_run(int start_line)

This api is use to start ro run the file passed by the ProgramOpen API from thestart_line.
Example: int ok = elephant_client.program_run(0)0 will be return if success, the other means fail.

2.10. string read_next_error )This api is use to read the latest error occur in the robot, empty string will be returned
if there is no error.
Example: string error = elephant_client.read_next_error()

2.11. string get_variable(string var_name)

This api is use to get the value of var_name, if there is no variable named var_name,string “Variable does not exist” will be returned.
Example: string variable = elephant_client.get_variable(‘A’)

2.12. string assign_variable(string var_name, string var_value)

This api is use to assign var_value to var_name, if the type of var_name is string , thevar_value need to be quoted whit “.
Example: string res = elephant_client.assign_variable(‘A’, ‘”test”’)

2.13. void write_coords(array coords, int speed)This api is use to set the coordinate of the robot to coords. And the robot speed isspeed(unit: mm/minutte)
Example: elephant_client.write_coords([10, 20, 30, 10, 12.2, 15], 500)

2.14. void write_coord(int axis, double value, int speed)This api is use to set the coordinate of axis axis to value. And the robot speed isspeed(unit: mm/minutte)
Example: elephant_client.write_coord(0, 30.0, 500)
0 means axis x, 1 means axis y, 2 means axis z, 3 means rx, 4 means ry, 5 means rz.

2.15. void write_angles (array angles, int speed)This api is use to set the angle of the robot to angles. And the robot speed isspeed(unit: mm/minutte)Example: elephant_client.write_angles([10.0, 20.0, 30, 10, 12.2, 15], 500)

2.16. void write_angle (int joint, double value, int speed)This api is use to set the angle of joint joint to value. And the robot speed isspeed(unit: mm/minutte)
Example: elephant_client.write_angle(0, 30.0, 500)
0 means joint 1, 1 means joint 2, 2 means joint 3, 3 means joint 4, 4 means joint 5, 5means joint 6.

2.17. void set_speed (int speed)This api is use to set the speed of robot to speed, the unit of speed is mm/minute
Example: elephant_client.set_speed(500)

2.18. void set_torque_limit (string axis, double value)

This api is use to set the torque limit of axis axis to value(unit: N)Example: elephant_client.set_torque_limit(‘x’, 50)
The unit of torque is N.
Now the axis support ‘x’, ‘y’ and ‘z’.

2.19. void set_upside_down(bool upside_down)This api is use to tell the robot whether you have install the robot upside down
Example: elephant_client.set_upside_down(True)

2.20. void set_payload(double payload)

This api is use to set the payload of the robot to payload(unit: kg)
Example: elephant_client.set_payload(5.0)

2.21. void state_on()

This api is use to enable the system
Example: elephant_client.state_on()

2.22. void state_off()

This api is use to disable the system
Example: elephant_client.state_off()

2.23. void task_stop()

This api is use to stop the command that are excuting or going to excute.
Example: elephant_client.task_stop()

2.24. void jog_angle(string joint, int direction, int speed)This api is use to change the angle of joint joint in one direction continuously in thespeed of speed
Example: elephant_client.jog_angle(‘J1’, 1, 500)
The direction can be -1, 0, 1, -1 means in negative direction, 1 means positive
direction, 0 means stop.

2.25. void jog_coord(string axis, int direction, int speed)This api is use to change the coordinate of axis axix in one direction continuously inthe speed of speed
Example: elephant_client.jog_coord(‘x’, 1, 500)
The direction can be -1, 0, 1, -1 means in negative direction, 1 means positivedirection, 0 means stop.

2.26. int get_digital_in(int pin_number)This api is use to get the digital in signal of pin_number pin.
Example: int signal = elephant_client.get_digital_in(0)2.27. int get_digital_out(int pin_number)This api is use to get the digital out signal of pin_number pin.
Example: int signal = elephant_client.get_digital_ out(0)2.28. void set_digital_out(int pin_number, int pin_signal)

This api is use to set the digital out signal of pin_number pin to pin_signal
Example: elephant_client.set_digital_out(2, 1)

2.29. void set_analog_out(int pin_number, double pin_value)

This api is use to set the analog out signal of pin_number pin to pin_signal

Example: elephant_client.set_analog_out (2, 1.0)

2.30. int send_feed_override(double override)

set the feed override to override, 0 will be return if success, the other means fail.
Example: elephant_client.send_feed_override(50.0)

2.31. int get_acceleration()

This api is use to get the current acceleration of the robot.
Example: int acc = elephant_client.get_ acceleration()
the unit of acceleration is mm/s^22.32. void set_acceleration(int acceleration)

This api is use to set the acceleration of the robot to acceleration
Example: int acc = elephant_client.set_ acceleratio(50)the unit of acceleration is mm/s^22.33. int emc_command_wait_done()

This api is use to wait for previous command to be done, 0 will be return if success,the other means fail.
Example: elephant_client.emc_command_wait_done()

2.34. void wait(double senconds)

This api is use to wait for senconds second
Example: elephant_client.wait(10)