Skip to content

Subh85330/mock-serial-hardware-interface

Repository files navigation

Mock Serial ros2_control Hardware Interface

This package implements a custom ros2_control hardware interface for a single-joint robot that communicates with a mock serial motor driver. The system integrates with standard ROS 2 controllers and can be visualized in RViz2.


Prerequisites

Operating System

  • Ubuntu 22.04 (ROS 2 Humble)

Required ROS Packages

sudo apt update
sudo apt install \
  ros-humble-ros2-control \
  ros-humble-ros2-controllers \
  ros-humble-controller-manager \
  ros-humble-joint-state-broadcaster \
  ros-humble-joint-trajectory-controller \
  ros-humble-xacro \
  ros-humble-rviz2

Workspace Setup

Create a ROS 2 workspace if you don’t already have one:

mkdir -p ~/ros_ws2/src
cd ~/ros_ws2/src

Clone or copy this package into the src directory:

cd ~/ros_ws2/src
git clone https://github.com/Subh85330/mock-serial-hardware-interface.git

Build Instructions

Source your ROS 2 environment:

source /opt/ros/humble/setup.bash

Build the package:

cd ~/ros_ws2
colcon build --packages-select mock_serial_hardware

Source the workspace:

source install/setup.bash

Launching the System

Launch the ros2_control system, robot_state_publisher, and RViz:

ros2 launch mock_serial_hardware mock_system.launch.py

You should see:
ros2_control_node running
Hardware interface initialized and activated
Configured and activated joint_state_broadcaster
Configured and activated joint_position_controller
RViz window opened

Sending a Command

Move the joint using a trajectory command:

ros2 topic pub /joint_position_controller/joint_trajectory \
trajectory_msgs/msg/JointTrajectory "
joint_names: ['joint1']
points:
- positions: [1.0]
  time_from_start: {sec: 2}
"

RViz2 Visualization Setting already saved and automatically launches with the launch file

Set Fixed Frame to base
Added RobotModel and set description robot_description
Added TF

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published