Skip to content

Commit 4569ef8

Browse files
committed
ros2
1 parent 2a60c4c commit 4569ef8

12 files changed

Lines changed: 334 additions & 229 deletions

File tree

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@ completions/
1111
eval/
1212
test.py
1313
evaluation_script/*.png
14-
evaluation_script/*.pgf
14+
evaluation_script/*.pgf
15+
16+
build/
17+
devel/
18+
install/
19+
bin/
20+
log/

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
CodeBotler is a system that converts natural language task descriptions into robot-agnostic programs that can be executed by general-purpose service mobile robots. It includes a benchmark (RoboEval) designed for evaluating Large Language Models (LLMs) in the context of code generation for mobile robot service tasks.
88

99
This project consists of two key components:
10-
* [CodeBotler](#codebotler-deploy-quick-start-guide): This system features a web interface designed for generating general-purpose service mobile robot programs, along with a ROS (Robot Operating System) Action client for deploying these programs on a robot. It offers the flexibility to explore the code generation capabilities of CodeBotler in two ways: as a standalone system without a robot, as illustrated in the figure above, or by actual deployment on a real robot.
10+
* [CodeBotler](#codebotler-deploy-quick-start-guide): This system features a web interface designed for generating general-purpose service mobile robot programs, along with a ROS2 (Robot Operating System) Action client for deploying these programs on a robot. It offers the flexibility to explore the code generation capabilities of CodeBotler in two ways: as a standalone system without a robot, as illustrated in the figure above, or by actual deployment on a real robot.
1111

1212

1313
* [RoboEval](#roboeval-benchmark-quick-start-guide): This benchmark for code generation features a suite of 16 user task descriptions, each with 5 paraphrases of the prompt. It includes a symbolic simulator and a temporal trace evaluator, specifically designed to assess Large Language Models (LLMs) in their ability to generate code for service mobile robot tasks.
@@ -18,11 +18,16 @@ Project website: https://amrl.cs.utexas.edu/codebotler
1818

1919
We provide a conda environment to run our code. To create and activate the environment:
2020
```shell
21-
conda create -n codebotler python=3.12.8 pip
21+
conda create -n codebotler python=3.10 pip
2222
conda activate codebotler
2323
pip install -r requirements.txt
2424
```
25-
After installing the conda environment, please go to [pytorch's official website](https://pytorch.org/get-started/locally/) to install the pytorch corresponding to your cuda version (**Note: do not install the cpu version**).
25+
After installing the conda environment, please go to [pytorch's official website](https://pytorch.org/get-started/locally/) to install the pytorch corresponding to your cuda version (**Note: do not install the cpu version**).
26+
27+
**ROS2 Requirements**
28+
* For robot deployment, you will need ROS2 installed on your system. CodeBotler uses ROS2 actions for robot communication.
29+
* Install ROS2 following the [official ROS2 installation guide](https://docs.ros.org/en/humble/Installation.html).
30+
* The robot interface components will automatically install the required ROS2 Python packages (`rclpy`).
2631

2732
**Language Model Options**
2833
* To use an OpenAI model, you will need an [OpenAI key](https://platform.openai.com/account/api-keys), either saved in a file named `.openai_api_key`, or in the `OPENAI_API_KEY` environment variable.

codebotler.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
ros_available = False
2222
robot_available = False
2323
robot_interface = None
24+
rclpy_instance = None
2425
try:
25-
import rospy
26+
import rclpy
2627
ros_available = True
27-
rospy.init_node('ros_interface', anonymous=False)
28+
rclpy_instance = rclpy
29+
rclpy.init()
2830
except:
29-
print("Could not import rospy. Robot interface is not available.")
31+
print("Could not import rclpy. Robot interface is not available.")
3032
ros_available = False
3133

3234
httpd = None
@@ -272,8 +274,9 @@ def shutdown(sig, frame):
272274
robot_interface._cancel_goals()
273275
print("Waiting for 2s to preempt robot actions...")
274276
time.sleep(2)
275-
if ros_available:
276-
rospy.signal_shutdown("Shutting down Server")
277+
robot_interface.destroy_node()
278+
if ros_available and rclpy_instance is not None:
279+
rclpy_instance.shutdown()
277280
if httpd is not None:
278281
httpd.server_close()
279282
httpd.shutdown()
@@ -323,7 +326,7 @@ def main():
323326
parser.add_argument('--transcription-pipe', type=Path, help='Pipe from which to read audio transcriptions', default='/tmp/audio_pipe')
324327

325328
if ros_available:
326-
args = parser.parse_args(rospy.myargv()[1:])
329+
args = parser.parse_args(rclpy_instance.utilities.remove_ros_args())
327330
else:
328331
args = parser.parse_args()
329332

conda_environment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ channels:
55
dependencies:
66
- python=3.12.8
77
- pip
8-
- rospy
8+
- rclpy

robot_interface/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# CodeBotler Robot Interface
22

3-
CodeBotler utilizes [ROS actions](http://wiki.ros.org/actionlib) to execute generated code on a real robot.
3+
CodeBotler utilizes [ROS2 actions](https://docs.ros.org/en/humble/Tutorials/Intermediate/Writing-an-Action-Server-Client/Py.html) to execute generated code on a real robot.
44
[robot_interface/src/robot_client_interface.py](src/robot_client_interface.py) defines the action clients that CodeBotler uses to call the robot action servers. The action definitions are in [robot_interface/src/robot_actions_pkg/action](src/robot_actions_pkg/action). An example robot action server script is provided in [robot_interface/src/robot_server_example.py](src/robot_server_example.py) - the example server simply prints action calls to the terminal, along with the call arguments and the result.
55
You can use this example script as a template to implement the action servers for your robot.
66

77
## Build
88
To build the action messages and the CodeBotler client:
9-
1. Navigate to the `robot_interface` subdirectory and run `catkin_make`:
9+
1. Navigate to the `robot_interface` subdirectory and run `colcon build`:
1010
```bash
1111
cd robot_interface
12-
catkin_make
12+
colcon build
1313
```
14-
1. Source the Catkin workspace setup script:
14+
1. Source the ROS2 workspace setup script:
1515
```bash
16-
source devel/setup.bash
16+
source install/setup.bash
1717
```
18-
1. Optionally, add the Catkin workspace setup script to your `~/.bashrc` file to automatically source the setup script when opening a new terminal.
18+
1. Optionally, add the ROS2 workspace setup script to your `~/.bashrc` file to automatically source the setup script when opening a new terminal.
1919
```bash
20-
echo "source $(pwd)/devel/setup.bash" >> ~/.bashrc
20+
echo "source $(pwd)/install/setup.bash" >> ~/.bashrc
2121
```
2222

2323
## Usage
@@ -30,4 +30,4 @@ The robot-specific action server must be launched before running the deployment
3030
```bash
3131
python3 codebotler.py --robot --ip <robot_ip>
3232
```
33-
1. Open `http://<robot_ip>:8080/` in your browser to access the deployment interface.
33+
1. Open `http://<robot_ip>:8080/` in your browser to access the deployment interface.

robot_interface/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
rospkg
2-
empy
1+
rclpy

robot_interface/setup_robot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
pip install -r requirements.txt
4-
catkin_make
4+
colcon build
Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
1-
cmake_minimum_required(VERSION 3.0.2)
1+
cmake_minimum_required(VERSION 3.8)
22
project(robot_actions_pkg)
33

4-
find_package(catkin REQUIRED COMPONENTS
5-
rospy
6-
std_msgs
7-
actionlib_msgs
8-
)
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
97

10-
add_action_files(
11-
FILES
12-
Ask.action
13-
GetAllRooms.action
14-
GetCurrentLocation.action
15-
GoTo.action
16-
IsInRoom.action
17-
Say.action
18-
Pick.action
19-
Place.action
20-
PickUp.action
21-
PutDown.action
22-
PutIntoBasket.action
23-
RetrieveFromBasket.action
24-
GetReachableLocationsAroundObject.action
25-
)
8+
# find dependencies
9+
find_package(ament_cmake REQUIRED)
10+
find_package(rclcpp REQUIRED)
11+
find_package(std_msgs REQUIRED)
12+
find_package(action_msgs REQUIRED)
13+
find_package(rcl_action REQUIRED)
2614

27-
generate_messages(
28-
DEPENDENCIES
29-
std_msgs
30-
actionlib_msgs
31-
)
15+
# Generate action interfaces
16+
find_package(rosidl_default_generators REQUIRED)
3217

33-
catkin_package(
34-
CATKIN_DEPENDS rospy std_msgs
18+
set(action_files
19+
"action/Ask.action"
20+
"action/GetAllRooms.action"
21+
"action/GetCurrentLocation.action"
22+
"action/GetReachableLocationsAroundObject.action"
23+
"action/GoTo.action"
24+
"action/IsInRoom.action"
25+
"action/Pick.action"
26+
"action/PickUp.action"
27+
"action/Place.action"
28+
"action/PutDown.action"
29+
"action/PutIntoBasket.action"
30+
"action/RetrieveFromBasket.action"
31+
"action/Say.action"
3532
)
3633

37-
include_directories(
38-
${catkin_INCLUDE_DIRS}
34+
rosidl_generate_interfaces(${PROJECT_NAME}
35+
${action_files}
36+
DEPENDENCIES std_msgs action_msgs
3937
)
38+
39+
ament_export_dependencies(rosidl_default_runtime)
40+
41+
if(BUILD_TESTING)
42+
find_package(ament_lint_auto REQUIRED)
43+
ament_lint_auto_find_test_dependencies()
44+
endif()
45+
46+
ament_package()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
string obj
2-
string location
2+
string dst
33
---
44

55
---
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0"?>
2-
<package format="2">
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
34
<name>robot_actions_pkg</name>
45
<version>0.0.0</version>
56
<description>The robot_actions_pkg package</description>
@@ -8,20 +9,20 @@
89

910
<license>TODO</license>
1011

11-
<buildtool_depend>catkin</buildtool_depend>
12-
<build_depend>rospy</build_depend>
13-
<build_depend>std_msgs</build_depend>
14-
<build_depend>actionlib</build_depend>
15-
<build_depend>actionlib_msgs</build_depend>
16-
<build_export_depend>rospy</build_export_depend>
17-
<build_export_depend>std_msgs</build_export_depend>
18-
<build_export_depend>actionlib</build_export_depend>
19-
<build_export_depend>actionlib_msgs</build_export_depend>
20-
<exec_depend>rospy</exec_depend>
21-
<exec_depend>std_msgs</exec_depend>
22-
<exec_depend>actionlib</exec_depend>
23-
<exec_depend>actionlib_msgs</exec_depend>
12+
<buildtool_depend>ament_cmake</buildtool_depend>
13+
14+
<depend>rclcpp</depend>
15+
<depend>rclpy</depend>
16+
<depend>std_msgs</depend>
17+
<depend>action_msgs</depend>
18+
<depend>rcl_action</depend>
19+
20+
<test_depend>ament_lint_auto</test_depend>
21+
<test_depend>ament_lint_common</test_depend>
22+
23+
<member_of_group>rosidl_interface_packages</member_of_group>
2424

2525
<export>
26+
<build_type>ament_cmake</build_type>
2627
</export>
27-
</package>
28+
</package>

0 commit comments

Comments
 (0)