Joint Control
For a serial multi-joint robot, the control of the joint space is to control the variables of each joint so as to make each joint reaches a target position at a certain speed.
Notice: When setting the angle, the values corresponding to different manipulators are different. Refer to the parameter introduction section for more information.
myPalletizer 260
Simple Demo
from pymycobot.mypalletizer import MyPalletizer260
import time
# import the project package
# Initiate a MyPalletizer260 object, M5 version
mc = MyPalletizer260("COM3",115200)
# PI version
# mc = MyPalletizer260("/dev/ttyAMA0",1000000)
# By passing the angle parameter, let each joint of the robotic arm move to the position corresponding to [0, 0, 0, 0, speed]
mc.send_angles([0, 0, 0, 0,], 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2)
# Move joint 1 to the 50 position
mc.send_angle(1,20,50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2)
# set variable "num"
num = 2
# set the number of loops
while num > 0:
mc.send_angle(2,20,50)
time.sleep(2)
mc.send_angle(2,(-20),50)
time.sleep(2)
num -= 1
# make robot arms reach the specified position
mc.send_angles([-0.87, 41.66, -12.13, -0.17], 50)
# Let the robotic arm relax, you can manually swing the robotic arm
mc.release_all_servos()
mechArm 270
Single-Joint Control
send_angle(id, degree, speed)
- Function: to sends a specified single joint motion to a specified angle.
- Parameters:
id
: to stand for the joints of a robot arm. represented by numbers 1-6.degree
: means the angle of a joint.speed
: means the movement speed of the robot arm, ranging from 0 to 100.
- Return value: 1
set_encoder(joint_id, encoder, speed)
Function: to sends a specified single joint motion to a specified potential value.
Parameters:
joint_id
: to stand for the joints of a robot arm. represented by numbers 1-6.encoder
:means the potential value of the robot arm, ranging from 0 - 4096.speed
: means the movement speed of the robot arm, ranging from 1 to 100.
Return value: 1
Multi-Joint Control
get_angles()
Function: to get the angels of all joints.
Return Value:
List
: a list of floating point values which represent the angles of all joints
send_angles(degrees, speed)
- Function: to send all angles to all joints.
- Parameters:
degrees
: (List [float]) contains the angles of all joints.the length is 6; The representation method is [20, 20,20, 20, 20, 20]speed
: means the movement speed of the robot arm, ranging from 0 to 100.
- Return value: 1
set_encoders(encoders, sp)
- Function: Send potential values to all joints of the robotic arm.
- Parameters:
encoder
: means the potential of the robot arm, ranging from 0 - 4096, length is 6. The way to represent:[2048, 2048, 2048, 2048, 2048, 2048].sp
: means the movement speed of the robot arm, ranging from 0 to 100.
- Return value: 1
sync_send_angles(degrees, speed, timeout=15)
- Function: to send an angle synchronously; return when reaching a target point.
- Parameters:
degrees
: A list of angle values of each jointList[float]
.speed
: (int
) means the movement speed of the robot arm, ranging from 0 to 100.timeout
: The default time is 15s.
- Return value: 1
get_radians()
- Function: to get the radian of all joints.
- Return value:
list
: a list containing radian values of all joints
send_radians(radians, speed)
- Function: to send radian values to all joints.
- Parameters:
radians
:list
: a list containing radian values of all joints, ranging from -5 to 5.
- Return value: 1
Simple Demo
from pymycobot.mecharm270 import MechArm270
import time
# MechArm270 class initialization requires two parameters:
# The first is the serial port string, such as:
# linux: "/dev/ttyUSB0"
# or "/dev/ttyACM0"
# windows: "COM3"
# The second is the baud rate::
# M5 version is: 115200
#
# Example:
# mecharm-M5:
# linux:
# mc = MechArm270("/dev/ttyUSB0", 115200)
# or mc = MechArm270("/dev/ttyACM0", 115200)
# windows:
# mc = MechArm270("COM3", 115200)
# mecharm-raspi:
# mc = MechArm270("/dev/ttyAMA0", 1000000)
#
# Initiate a MechArm270 object
# Create object code here for windows version
mc = MechArm270("COM3", 115200)
# PI version
# mc = MechArm270("/dev/ttyAMA0", 1000000)
#By passing the angle parameter, let each joint of the robotic arm move to the position corresponding to [0, 0, 0, 0, 0, 0]
mc.send_angles([0, 0, 0, 0, 0, 0], 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2.5)
# Move joint 1 to the 90 position
mc.send_angle(1, 90, 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2)
# The following code can make the robotic arm swing left and right
# set the number of loops
while num > 0:
# Move joint 2 to the 50 position
mc.send_angle(2, 50, 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(1.5)
# Move joint 2 to the -50 position
mc.send_angle(2, -50, 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(1.5)
num -= 1
#Make the robotic arm retract. You can manually swing the robotic arm, and then use the get_angles() function to get the coordinate sequence,
# use this function to let the robotic arm reach the position you want.
mc.send_angles([88.68, -138.51, 155.65, -128.05, -9.93, -15.29], 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2.5)
# Let the robotic arm relax, you can manually swing the robotic arm
mc.release_all_servos()
myBuddy
single joint control
send_angle(id, joint, angle, speed)
Function Send one degree of joint to robot arm.
Parameters
id – 1/2/3 (L/R/W)
joint – 1 ~ 6
angle – int
speed – 1 ~ 100
Returns
- None
get_angle(id, joint_id)
Function Get the angle of a single joint
Parameters
id (int) – 1/2/3 (L/R/W).
joint_id (int) – 1 - 7 (7 is gripper)
set_encoder(id, joint_id, encoder, speed)
Function Set a single joint rotation to the specified potential value.
Parameters
id – 1/2/3 (L/R/W).
joint_id – 1 - 6.
encoder – The value of the set encoder.
Returns
- None
multi-joint control
get_angles(id)
Function Get the degree of all joints.
Parameters
id – 1/2 (L/R)
Returns
A float list of all degree.
Return type
list
send_angles(id, degrees, speed)
Function Send all angles to the robotic arm
Parameters
id – 1/2 (L/R).
degrees – [angle_list] len 6
speed – 1 - 100
set_encoders(id, encoders, speed)
Function Set the six joints of the manipulator to execute synchronously to the specified position.
Parameters
id – 1/2 (L/R).
encoders – A encoder list, length 6.
speed – speed 1 ~ 100
get_radians(id)
Function Get the radians of all joints
Parameters
id – 1/2 (L/R)
Returns
A list of float radians [radian1, …]
Return type
list
send_radians(id, radians, speed)
Function Send the radians of all joints to robot arm
Parameters
id – 1/2 (L/R).
radians – a list of radian values( List[float]), length 6
speed – (int )1 ~ 100
Simple Demo
from pymycobot.mybuddy import MyBuddy
import time
mc = MyBuddy("/dev/ttyACM0", 115200)
# Send angles to the six joints of the left arm
mc.send_angles(1, [0, 0, 0, 0, 0, 0], 50)
time.sleep(3)
# Send the angle to the first joint of the left arm
mc.send_angle(1, 1, 90, 50)
time.sleep(2)
# Get the joint angle of the left arm
angles = mc.get_angles(1)
print("left angles: ",angles)
# Relax all joints of the left arm. Before running this command, please support the left arm with your hand to prevent it from falling suddenly
mc.release_all_servos(1)
myArm
Simple Demo
from pymycobot.myarm import MyArm
from pymycobot.genre import Angle
import time
# import the project package
# Initiate a MyArm object
mc = MyArm("/dev/ttyAMA0", 115200)
# By passing the angle parameter, let each joint of the robotic arm move to the position corresponding to [0, 0, 0, 0, 0, 0, 0,speed]
mc.send_angles([0, 0, 0, 0, 0, 0, 0], 50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2)
# Move joint 1 to the 90 position
mc.send_angle(1,90,50)
# Set the waiting time to ensure that the robotic arm has reached the specified position
time.sleep(2)
# set variable "num"
num = 2
# set the number of loops
while num > 0:
mc.send_angle(2,20,50)
time.sleep(2)
mc.send_angle(2,(-20),50)
time.sleep(2)
num -= 1
# make robot arms reach the specified position
mc.send_angles([-5.25,-30,-20,-12,-10,-10,10],50)
# Let the robotic arm relax, you can manually swing the robotic arm
mc.release_all_servos()