This project implements the control system for the Ares2 robot, including the LocoController (a motion controller that listens to velocity or torque commands) and the JoystickInterface (which maps joystick inputs to velocity commands). The system is designed to run on the actual robot using tmotor hardware.
Before building and running the project, ensure you have the following prerequisites installed:
The project is built for ROS 2 Humble. Follow the instructions for installing ROS 2:
Install the required ROS 2 packages:
sudo apt update
sudo apt install ros-humble-rclcpp ros-humble-geometry-msgs ros-humble-sensor-msgs ros-humble-std-msgs
You need the tmotor library for motor control.
-
Build the
tmotor
library as a ROS 2 package:- Clone the
tmotorcan_cpp
repository into your workspace. - Build it using colcon.
colcon build --packages-select tmotorcan_cpp
- Clone the
-
Make sure the library is installed in
ros2_ws/install/tmotorcan_cpp/lib
and the header is inros2_ws/install/tmotorcan_cpp/include
.
You will need the ares2_msgs package, which defines the necessary custom messages for this project:
-
Clone the ares2_msgs package into your workspace:
cd ~/ros2_ws/src git clone https://github.com/Ozyegin-Planetary-Robotics-Laboratory/ares2_msgs.git
-
Build the package using colcon:
colcon build --packages-select ares2_msgs
-
Clone the Ares2 Control System into your ROS 2 workspace:
cd ~/ros2_ws/src git clone https://github.com/Ozyegin-Planetary-Robotics-Laboratory/ares2_control.git
-
Build the workspace:
cd ~/ros2_ws colcon build
-
Source the workspace:
source install/setup.bash
-
Bring up the CAN interface for motor communication:
sudo ip link set can0 type can bitrate 500000 sudo ip link set up can0
-
Run the control node:
ros2 launch ares2_control launch.py
To control the robot using a joystick:
- Ensure a joystick is connected to your machine.
- Use the JoystickInterface to map joystick axes to the robot’s velocity control:
The
ros2 topic echo /cmd_vel
/cmd_vel
topic should publish velocity commands based on joystick input.
ares2_control
├── CMakeLists.txt # Build instructions
├── package.xml
├── include
├── LocoController.hpp
│ └── JoystickInterface.hpp # Header files for the controllers
├── launch # Launch files to run the system
└── launch.py
└── src
└── main.cpp # Node instantiating
This README provides the necessary steps to build and run the Ares2 control system on actual hardware. Ensure that all dependencies are installed, and follow the instructions to test the system with motors and a joystick.