# Developing environment and construction for MechArm 270-Pi

As the most compact collaborative robot, mechArm 270-Pi is portable. It’s tough but reliable for its centrosymmetric structure, and its effectiveness enables users to increase programming efficiency with reliability. Now we will talk about how to develop and construct the mechArm 270-Pi in different environments.

Because mechArm 270 Pi is supported by Ubantu (V-18.04) system, which has built-in Python, myStudio, myBlockly, ROS, OpenCV and driver libraries, so there is no need to download the development software and install the development environment (additional Python libraries need to be installed by yourself), we only need to prepare a monitor to connect the robotic arm.

1. myBlockly
myBlockly embodies the idea of drag-and-drop programming and is a graphical programming software and visualization tool. We can build code logic by dragging and dropping modules. The process is very similar to building blocks. Through myBlockly, we can control the mechArm to dance and sway, and control its joint and light.

First, we shall connect mechArm to MyBlockly. Click the red button and expand the Tools view, choose the port and set the Baud rate to 1000000.

To motivate and move mechArm-Pi, we are going to learn the Angel and Coordinates model.
1) Angel

This function can get the current angle of each joint of the robot arm.

This function enables a certain joint to move towards a set angle with a set speed.

Note: the Joints from bottom to top are respectively J1 to J6.

This function enables multiple joints to move towards set angles together with a set speed.

2) Coordinates

This function can get the current coordinates of the robot arm (x, y, z, rx, ry, rz)

This function enables the manipulator to move to the set coordinates with a set speed to reach the specified coordinates.

The mode can be adjusted to linear and non-linear (angular).

Linear: Intelligently plan the route, allowing the end (6th axis) of the robotic arm moves to the specified point in a straight line.

Angular: randomly plan the route as long as the end (6th axis) of the robotic arm moves to the specified point with the specified attitude.

2. Python
MechArm 270-Pi is very friendly to python, and the development of python API library is also increasingly perfect. Through Python, we can control many aspects like the joint angle, coordinates, gripper of the mechArm.

Here is the example about how to control the robot arm to make it return to the origin(It can be used in myCobot and mechArm):

``````from pymycobot.mycobot import MyCobot
from pymycobot import PI_PORT, PI_BAUD      # When using the Raspberry Pi version of mycobot, you can refer to these two variables to initialize MyCobot

# MyCobot class initialization requires two parameters:
#   The first is the serial port string, such as:
#       linux: "/dev/ttyUSB0"
#          or "/dev/ttyAMA0"
#       windows: "COM3"
#   The second is the baud rate:
#       M5 version is: 115200
#
#    Example:
#       mycobot-M5:
#           linux:
#              mc = MyCobot("/dev/ttyUSB0", 115200)
#          or mc = MyCobot("/dev/ttyAMA0", 115200)
#           windows:
#              mc = MyCobot("COM3", 115200)
#       mycobot-raspi:
#           mc = MyCobot(PI_PORT, PI_BAUD)
#
# Initialize a MyCobot object
# Create object code here for Raspberry Pi version
mc = MyCobot(PI_PORT, PI_BAUD)

# Check whether the program can be burned into the robot arm
if mc.is_controller_connected() != 1:
print("Please connect the robot arm correctly for program writing")
exit(0)

# Fine-tune the robotic arm to ensure that all the bayonets are aligned in the adjusted position
# Subject to the alignment of the mechanical arm bayonet, this is only a case
mc.send_angles([0, 0, 0, 0, 0, 0], 30)

# To calibrate the position at this time, the calibrated angular position represents [0,0,0,0,0,0], and the potential value represents [2048,2048,2048,2048,2048,2048]
# The for loop is equivalent to the method set_gripper_ini()
#for i in range(1, 7):
#mc.set_servo_calibration(i)
``````

3. Base on ROS
ROS is an open source and a post-operating system, or we can say it is a secondary operating system for robot control. Through ROS, we can realize the simulation control of the manipulator in the virtual environment. We will visualize the mechArm through the rviz platform, and operate it in a variety of ways, such as slider controlling, model following, Keyborad controlling. Then plan and execute the mechArm’s action path through the moveit platform to achieve the effect of freely controlling the robotic arm.

Here is the example about the model following:

Open a command line and run:

``````
# The default serial port name of the mechArm version is "/dev/ttyAMA0", and the baud rate is 1000000".

rosrun mecharm_pi follow_display.py _port:=/dev/ttyAMA0 _baud:=1000000

``````

Then open another command line and run:

``````
roslaunch mecharm_pi follow.launch

``````

It will open rviz to show the model following effect.

MechArm 270-Pi is very easy to use and program, it can also be programmed to be a life assistant such as a gardener, a patrol, or a writer for you. Its reliability and effectiveness provide you more space to develop your imagination and creation. If you get a mechArm, how do you plan to use it? As a programming tool or service assistant? Share with us in the comment!

2 Likes

So this product is based on Raspberry Pi?

1 Like

Yes you are right!!