This ROS 2 package, navigation_controler, provides a simple TCP-based interface to send navigation goals to a ROS 2 action server. It includes both the ROS 2 action client (nav_ctrl.cpp
) and a Python client script (client_nav.py
) for sending navigation requests.
- Accepts TCP connections to receive navigation goals in the format
x,y,z
. - Sends goals to the ROS 2 Navigation stack using the
nav2_msgs/action/NavigateToPose
action. - Supports feedback on the goal's status and completion.
navigation_controler/
├── client_nav.py # Python client script for sending navigation requests
├── CMakeLists.txt # CMake build configuration for the ROS 2 package
├── nav_ctrl.cpp # ROS 2 action client with TCP server
├── package.xml # ROS 2 package manifest
├── README.md # Documentation for the package
Ensure ROS 2 is installed on your system. Follow the instructions on the ROS 2 Installation Page.
Run the following commands to install the necessary dependencies:
-
Install ROS 2 dependencies:
sudo apt update sudo apt install -y ros-${ROS_DISTRO}-nav2-msgs ros-${ROS_DISTRO}-rclcpp ros-${ROS_DISTRO}-rclcpp-action
-
Install Boost libraries:
sudo apt install -y libboost-all-dev
-
Install Python dependencies:
pip install --upgrade pip pip install socket
Note: Replace
${ROS_DISTRO}
with your ROS 2 distribution (e.g.,humble
orfoxy
).
-
Clone the repository into your ROS 2 workspace:
cd ~/ros2_ws/src git clone <repository_url> navigation_controler
-
Navigate to the workspace root and build:
cd ~/ros2_ws colcon build --packages-select navigation_controler
-
Source the workspace:
source ~/ros2_ws/install/setup.bash
To start the ROS 2 action client with the embedded TCP server:
ros2 run navigation_controler nav_ctrl
You should see output indicating the TCP server is running, e.g.:
[INFO] [pose_action_client]: TCP Server started on IP: 0.0.0.0, Port: 12345
Use the provided Python script to send navigation requests to the server:
- Ensure the server is running.
- Run the client script:
python3 ~/ros2_ws_v2/src/navigation_controler/client_nav.py
This script sends a navigation goal in the format x,y,z
to the TCP server.
Example output:
Send start
Received from server: Goal accepted
Modify client_nav.py
to customize the navigation goal:
send_navigation_request("127.0.0.1", 12345, 3.5, 2.0, 0.0)
Change the coordinates as needed and rerun the script to test different goals.
-
TCP Server not accepting connections:
- Verify the port is not in use by another application.
- Ensure the firewall settings allow connections to the server.
-
No feedback from the action server:
- Ensure the Navigation 2 stack is running and configured correctly.
- Check ROS 2 topics and services for errors.
This package is licensed under the Apache 2.0 License. See LICENSE for details.