Examples: Basics
In this file, two short programs are implemented & commented in order to help you understand the philosophy behind the PyNiryo package.
Danger
If you are using the real robot, make sure the environment around it is clear.
Your first move joint
The following example shows a first use case. It’s a simple MoveJ.
1from pyniryo import NiryoRobot, JointsPosition
2
3robot = NiryoRobot('<robot_ip_address>')
4
5robot.calibrate_auto()
6
7robot.move(JointsPosition(0.2, -0.3, 0.1, 0.0, 0.5, -0.8))
8
9robot.close_connection()
Code Details - First Move J
First of all, we import the library to be able to access functions.
1from pyniryo import NiryoRobot, JointsPosition
Then, we instantiate the connection and link the variable robot
to the robot
by giving its IP Address.
Note
Don’t know what’s the robot IP address ? Take a look at How to Find your Robot’s IP address
3robot = NiryoRobot('<robot_ip_address>')
Once the connection is done, we calibrate the robot using its
calibrate_auto()
function.
5robot.calibrate_auto()
As the robot is now calibrated, we can do a Move Joints by giving the 6 axis positions
in radians! To do so, we use move()
with a JointsPosition
object.
7robot.move(JointsPosition(0.2, -0.3, 0.1, 0.0, 0.5, -0.8))
Our process is now over, we can close the connection with
close_connection()
.
9robot.close_connection()
Your first pick and place
In the second example, we are going to develop a pick and place algorithm.
1from pyniryo import NiryoRobot, PoseObject
2
3robot = NiryoRobot('<robot_ip_address>')
4
5robot.calibrate_auto()
6robot.update_tool()
7
8robot.release_with_tool()
9robot.move(PoseObject(0.19, -0.12, 0.24, -3.14, 0.01, -0.1))
10robot.grasp_with_tool()
11
12robot.move(PoseObject(0.2, 0.09, 0.25, -3.14, -0.0, -0.03))
13robot.release_with_tool()
14
15robot.close_connection()
Code Details - First Pick And Place
First of all, we import the library and start the connection between our computer and the robot. We also calibrate the robot.
1from pyniryo import NiryoRobot, PoseObject
2
3robot = NiryoRobot('<robot_ip_address>')
4
5robot.calibrate_auto()
Then, we equip the tool
with update_tool()
.
6robot.update_tool()
Now that our initialization is done, we can open the gripper (or push air from the vacuum)
with release_with_tool()
,
go to the picking pose via move()
& then catch an object
with grasp_with_tool()
!
8robot.release_with_tool()
9robot.move(PoseObject(0.19, -0.12, 0.24, -3.14, 0.01, -0.1))
10robot.grasp_with_tool()
We now get to the place pose, and place the object.
12robot.move(PoseObject(0.2, 0.09, 0.25, -3.14, -0.0, -0.03))
13robot.release_with_tool()
Our process is now over, we can close the connection.
15robot.close_connection()