Wiznet makers

Benjamin

Published May 28, 2024 © MIT license (MIT)

43 UCC

11 WCC

4 VAR

0 Contests

0 Followers

1 Following

Original Link

Cybergear ROS2 Controller

This package is for controlling Cybergear on M5Stack. By using Micro-ROS, you can control multiple Cybergears via Ethernet (RJ45)

COMPONENTS
PROJECT DESCRIPTION

In the realm of advanced robotics and automation, seamless and efficient communication between devices is crucial. One of the standout solutions in this space is the Cybergear ROS2 Controller package, leveraging the power of WIZnet's LAN Module W5500 with PoE V12. This article delves into the intricacies of this technology, exploring its components, setup, and the significant advantages it offers to developers and engineers.

Introduction to Cybergear ROS2 Controller

The Cybergear ROS2 Controller package is designed to control multiple Cybergears via Ethernet (RJ45) using Micro-ROS. This capability is critical for applications that require real-time data transmission and control over Ethernet networks. The package is built to work with the M5Stack hardware series, specifically the M5Stack Basic and M5Stack AtomS3, making it versatile for various development environments.

Key Hardware Components

The Cybergear ROS2 Controller utilizes the following hardware components:

Case 1: M5Stack Basic Setup

image
  • M5Stack Basic V2.7: A compact and powerful development kit ideal for IoT and embedded applications.
  • LAN Module W5500 with PoE V12: Provides Ethernet connectivity with Power over Ethernet (PoE) capability, eliminating the need for separate power supplies.
  • Xiaomi Cybergear: The primary device being controlled, known for its precision and reliability.
  • XT30(2+2)-F Connectors and Grove Cable: For easy and secure connections.

Case 2: M5Stack AtomS3 Setup

image
  • M5Stack AtomS3 Dev Kit with 0.85-inch Screen: A smaller, yet highly capable version of the M5Stack series.
  • ATOMIC PoE Base W5500: Similar to the LAN Module W5500, this provides PoE functionality.
  • Mini CAN Unit (TJA1051T/3): Enables Controller Area Network (CAN) communication, crucial for real-time data exchange in automotive and industrial applications.
  • XT30(2+2)-F Connectors and Grove Cable: Ensures reliable connections.

 

Development Environment and Setup

To get started with the Cybergear ROS2 Controller, developers need to set up their development environment. The recommended setup includes:

  • Operating System: Ubuntu 22.04
  • ROS2 Distribution: ROS2 Humble
  • IDE: Visual Studio Code with PlatformIO plugin

Cloning and Setting Up the Repository

1.Clone the Repository:

git clone git@github.com:chikuta/cybergear_micro_ros_m5.git
code cybergear_micro_ros_m5

2.Modify PlatformIO Environments: Update the platformio.ini file to match your specific module:

  • For M5Stack + LAN Module W5500: env:m5stack-core-esp32
  • For AtomS3 + LAN Module W5500: env:m5stack-atoms3-esp32

3.Build the Micro-ROS Arduino Library: Navigate to the micro_ros_arduino directory and apply the necessary patches:

cd .pio/libdeps/m5stack-core-esp32/micro_ros_arduino # Adjust for AtomS3 as needed
patch -p1 < ../../../../patch/colcon.meta.patch
docker pull microros/micro_ros_static_library_builder:humble
docker run -it --rm -v $(pwd):/project --env MICROROS_LIBRARY_FOLDER=extras microros/micro_ros_static_library_builder:humble -p esp32

4.Copy Example Files:

cd cybergear_micro_ros_m5/src
cp examples/cybergear_ros2_controller_m5stack_core/cybergear_ros2_controller_m5stack_core.ino . # Adjust for AtomS3 as needed

Build and Upload the Firmware: Use VSCode to build and upload the binary to the M5Stack device.

Configuring the Firmware

Customize the network and Cybergear configurations in the source code to match your development environment:

Network Configuration

byte local_mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED};
const IPAddress local_ip(192, 168, 50, 200);
const IPAddress host_ip(192, 168, 50, 76);
const uint16_t host_port = 2000;

Cybergear Configuration

static const uint8_t MOTOR_NUM = 2;
const std::vector<std::string> joint_names = {"mot1", "mot2"};
const std::vector<uint8_t> motor_ids = {0x7F, 0x7E};
 
 

Running the Cybergear Controller

Before running the demo, ensure the Cybergear firmware is up-to-date and CAN IDs are set to 0x7E and 0x7F.

  1. Launch the Micro-ROS Agent:
docker run -it --rm --privileged --net=host microros/micro-ros-agent:humble udp4 --port 2000

     2. Check ROS2 Connection:

ros2 topic list
ros2 service list
ros2 param list

     3. Start the Cybergear Controller:

ros2 service call /cgc_node/control_power std_srvs/srv/SetBool data:\ true
source /opt/ros/$ROS_DISTRO/setup.bash
cd cybergear_micro_ros_m5/scripts
python3 cybergear_example.py

     4. Disable the Cybergear Controller:

ros2 service call /cgc_node/control_power std_srvs/srv/SetBool data:\ false
image

ROS2 Parameters and Safety

The Cybergear ROS2 Controller offers extensive parameter customization. However, it is essential to exercise caution when modifying control gains to prevent the Cybergear from becoming unstable or causing harm.

Key ROS2 Parameters

  • run_mode: Determines the control mode (motion, position, speed, current).
  • limit_speed: Sets the maximum speed of Cybergear.
  • limit_current: Sets the maximum current.
  • limit_torque: Sets the maximum torque.
  • loc_kp, spd_kp, spd_ki, cur_kp, cur_ki: Control gains for position, speed, and current control loops.

Advantages of Using LAN Module W5500 with PoE V12

The LAN Module W5500 with PoE V12 by WIZnet offers several advantages that enhance the performance and usability of the Cybergear ROS2 Controller:

  1. Power over Ethernet (PoE): Simplifies installation by combining power and data transmission over a single Ethernet cable, reducing wiring complexity and costs.
  2. Reliable Ethernet Connectivity: Ensures stable and high-speed data communication, essential for real-time control applications.
  3. Low Power Consumption: Optimized for energy efficiency, making it suitable for battery-powered and remote applications.
  4. Ease of Integration: The module's compatibility with popular microcontroller platforms like M5Stack simplifies the development process.

Conclusion

The integration of WIZnet's LAN Module W5500 with PoE V12 in the Cybergear ROS2 Controller package unlocks new possibilities for developers working on robotics and IoT applications. By leveraging Ethernet connectivity and the robust features of Micro-ROS, this setup provides a powerful and flexible solution for controlling multiple Cybergears in real-time. Whether you are developing for industrial automation, smart infrastructure, or advanced robotics, this combination offers the performance, reliability, and ease of use required to succeed.

Documents
  • src

Comments Write