How ROS is used in mechArm 270-Pi?

As an open-source meta-operating system used for robots, ROS is widely used in many robotics products, also in mechArm 270-Pi. Through the ROS system, we can simulate the control of robotic arms in a virtual environment. We will visualize robot arms through rviz, operates our robot arms in a variety of ways, and also plan and execute the action path through Moveit to control the mechArm. Now we will talk about how to control mechArm 270-Pi in rviz and Moveit.

rviz

rviz is a 3D visualization platform in ROS. It can graphically display external information. Meanwhile, we can also get the controlling information to an object through rviz, and realize the monitoring and control of a robot, such as the control of slider, GUI and keyboard, and model following. Here we’re going to demonstrate how to implement these functions.

1.Slider Control
Open a terminal or command line and run :


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

roslaunch mecharm_pi slider_control.launch port:=/dev/ttyAMA0 baud:=1000000

rviz and a slider component will be opened, and we will see the following interface:
滑动控制_Trim
Then we can control the model in rviz to make it move by dragging the slider. If we want the real mechArm to move with the model, we need to open another 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 slider_control.py _port:=/dev/ttyAMA0 _baud:=1000000

Note: Since the robot arm will move to the current position of the model when the command is input, make sure that the model in rviz does not appear to be worn out before we use the command.

Note: Do not drag the slider immediately and too quickly after connecting the mechArm to prevent damages to the robot arm.
真实-滑动控制_Trim_Trim_Trim

2.GUI control
Based on the previous contents, this package also provides a simple GUI control interface. This method is used to control the real robot arms. We should connect to mecharm first.

Open a command line:


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

roslaunch mecharm_pi simple_gui.launch port:=/dev/ttyAMA0 baud:=1000000

Running effect:

3.Keyboard control
Keyboard control is added in mecharm package, and real-time Synchronization is performed in rviz. This function depends on pythonApi, so be sure to connect with the real robot arm.

Open a command line and run:


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

roslaunch mecharm_pi teleop_keyboard.launch port:=/dev/ttyAMA0 baud:=1000000

Running effect is as follows:
键盘控制
We can control the mechArm by keyboard as instructed in the command line, mechArm information will be output in the command line as follows:

SUMMARY
========

PARAMETERS
 * /mecharm_services/baud: 1000000
 * /mecharm_services/port: /dev/ttyAMA0
 * /robot_description: <?xml version="1....
 * /rosdistro: melodic
 * /rosversion: 1.14.11

NODES
  /
    mecharm_services (mecharm_communication/mypal_services.py)
    real_listener (mecharm_pi/listen_real.py)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    rviz (rviz/rviz)

ROS_MASTER_URI=http://localhost:11311

process[robot_state_publisher-1]: started with pid [14764]
process[rviz-2]: started with pid [14765]
process[mecharm_services-3]: started with pid [14766]
process[real_listener-4]: started with pid [14782]
[INFO] [1646649869.148017]: start ...
[INFO] [1646649869.156531]: /dev/ttyAMA0,1000000

Mycobot Status
--------------------------------
Joint Limit:
    joint 1: -160 ~ +160
    joint 2: -90 ~ +90
    joint 3: -180 ~ +45
    joint 4: -160 ~ +160
    joint 5: -100 ~ +100
    joint 6: -180 ~ +180

Connect Status: True

Servo Infomation: unknown

Servo Temperature: unknown

Atom Version: unknown

[INFO] [1646649869.427899]: ready

Then open another command line and run:

rosrun mecharm_pi teleop_keyboard.py
# or
rosrun mecharm_pi teleop_keyboard.py _speed:=70

We will see the following output in the command line:

mecharm Teleop Keyboard Controller
---------------------------
Movimg options(control coordinations [x,y,z,rx,ry,rz]):
              w(x+)

    a(y-)     s(x-)     d(y+)

        z(z-)       x(z+)

u(rx+)      i(ry+)      o(rz+)
j(rx-)      k(ry-)      l(rz-)

Gripper control:
    g - open
    h - close

Other:
    1 - Go to init pose
    2 - Go to home pose
    3 - Resave home pose
    q - Quit

currently:    speed: 40    change percent: 5

Parameters supported by this script:

_speed: the movement speed of the robot arm
_change_percent: movement distance percentage

4.Model Following
In addition, we can also make the model follow the movement of the real robotic arm. 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.
跟随控制

5.Moveit
As an integrated development platform in ROS, Moveit consists of a variety of functional packages for manipulating robot arms, including motion planning, operation, control, inverse kinematics, 3D perception, and collision detection.

For mechArm 270-Pi, mycobot_ros has integrated the MoveIt section, so we need to open the command line and run:


roslaunch mecharm_pi_moveit mecharm_moveit.launch

The operation effect is as follows:


If we want a real robot arm to execute a plan synchronously, we need to open another 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_moveit sync_plan.py _port:=/dev/ttyAMA0 _baud:=1000000

With the support of the ROS system, we can control mechArm and conduct algorithm verification under a virtual environment, which reduces the requirements for the experimental environment and improves efficiency.

Should you have any ideas about using ROS in the robotic arm for more functions, please share with us in the comment.

3 Likes

Thanks for the elaborate documentation.

1 Like

You are welcome :grinning: Hope that this can help you

Good share! I will buy one mechArm to program

1 Like