Skip to content

Conversation

@nathantsoi
Copy link

No description provided.

@nathantsoi nathantsoi requested a review from Copilot October 25, 2025 18:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the UT Automata codebase from ROS 1 to ROS 2, updating dependencies, message types, APIs, and build infrastructure to support the new framework.

Key Changes:

  • Complete migration from ROS 1 to ROS 2 APIs (roscpp → rclcpp)
  • Updated message includes and type namespaces (e.g., sensor_msgs::LaserScansensor_msgs::msg::LaserScan)
  • Converted launch files from XML to Python format
  • Updated build system from rosbuild to ament_cmake

Reviewed Changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/websocket/websocket_main.cc Migrated to rclcpp, updated time/clock APIs, added graceful shutdown
src/websocket/websocket.h Updated message type namespaces, added shutdown methods
src/websocket/websocket.cc Updated message types and time initialization
src/vesc_driver/vesc_driver_node.cpp Migrated to rclcpp node creation and spinning
src/vesc_driver/vesc_driver.h Updated to rclcpp publishers/subscribers and timer
src/vesc_driver/vesc_driver.cpp Migrated time APIs, callbacks, and added joystick mode config
src/simulator/vector_map.cc Added default initialization for Vector2f
src/simulator/step_simulator_main.cc Converted to ROS 2 with rclcpp APIs and parameters
src/simulator/simulator_main.cc Basic ROS 2 node migration
src/simulator/simulator.h Updated to rclcpp publishers/subscribers and tf2
src/simulator/simulator.cc Migrated to tf2, rclcpp time, and ament package paths
src/joystick/joystick_driver.cc Added Bluetooth controller detection and auto-connection
src/gui/gui_mainwindow.h Added camera display, disk space, and tmux controls
src/gui/gui_mainwindow.cc Implemented camera feed, tmux management, instance locking
src/gui/gui_main.cc Migrated to rclcpp with proper shutdown and timeout detection
scripts/udev.sh Added udev rule setup script for DualShock 4
scripts/keyboard_teleop.py Converted from rospy to rclpy
scripts/joystick_teleop.py Converted from rospy to rclpy with corrected message type
package.xml Added ROS 2 package manifest
msg/VescStateStamped.msg Fixed header type reference
launch/*.py Converted launch files to ROS 2 Python format
config/joystick.lua Updated defaults and added joystick mode config
Makefile Changed default build mode to Hardware
CMakeLists.txt Complete migration to ament_cmake build system
.github/workflows/buildTest.yml Updated CI to use ROS 2 Humble container

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const auto now = ros::Time::now();
if ((now - laser_scan_.header.stamp).toSec() > FLAGS_max_age) {
laser_scan_.header.stamp = ros::Time(0);
const auto now = rclcpp::Clock().now();
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new rclcpp::Clock() instance on each call is inefficient. Consider creating a single clock instance and reusing it, or use a node's clock via node->get_clock()->now().

Copilot uses AI. Check for mistakes.
map.toStdString().c_str(), x, y, math_util::RadToDeg(theta));
}
initial_pose_msg_.header.stamp = ros::Time::now();
initial_pose_msg_.header.stamp = rclcpp::Clock().now();
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new rclcpp::Clock() instance on each call is inefficient. Consider using a node's clock via node->get_clock()->now() since a node is available in this scope.

Copilot uses AI. Check for mistakes.
CONFIG_STRING(serial_port_, "serial_port");

DEFINE_string(config_dir, "config",
DEFINE_string(config_dir, "/home/orin/roboracer_ws/src/ut_automata/config",
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute path /home/orin/roboracer_ws/src/ut_automata/config reduces portability. Consider using ament_index_cpp::get_package_share_directory() to locate the config directory relative to the installed package.

Copilot uses AI. Check for mistakes.
void VescDriver::checkCommandTimeout() {
static const double kTimeout = 0.5;
const double t_now = ros::WallTime::now().toSec();
const double t_now = rclcpp::Clock(RCL_ROS_TIME).now().seconds();
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new rclcpp::Clock instance on each call is inefficient. Consider storing the clock instance as a member variable and reusing it.

Copilot uses AI. Check for mistakes.
Comment on lines +264 to +268
size_t min_axes = 5; // Default for "both" mode (needs axes 0 and 4)
if (joystick_mode_ == "left") {
min_axes = 2; // Needs axes 0 and 1
} else if (joystick_mode_ == "right") {
min_axes = 5; // Needs axes 3 and 4
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers 5, 2, and 5 for min_axes are unclear. Define named constants like kMinAxesBoth = 5, kMinAxesLeft = 2, kMinAxesRight = 5 to improve readability and maintainability.

Copilot uses AI. Check for mistakes.
void SaveControllerMAC(const string& mac_address) {
if (mac_address.empty()) return;

string config_file = string(getenv("HOME")) + "/roboracer_ws/car/joystick_controller_mac.txt";
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded path /roboracer_ws/car/joystick_controller_mac.txt reduces portability. Consider using a more flexible path or storing configuration in a standard location like ~/.config/ut_automata/.

Copilot uses AI. Check for mistakes.
// Get tmux configuration names (excluding "sim")
tmux_config_names_.clear();
tmux_config_buttons_.clear();
QDir tmux_dir("/home/orin/roboracer_ws/tmux");
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute path /home/orin/roboracer_ws/tmux reduces portability. Consider making this path configurable or using environment variables.

Suggested change
QDir tmux_dir("/home/orin/roboracer_ws/tmux");
QString tmux_dir_path = QString::fromUtf8(qgetenv("ROBORACER_TMUX_DIR"));
if (tmux_dir_path.isEmpty()) {
tmux_dir_path = "/home/orin/roboracer_ws/tmux";
}
QDir tmux_dir(tmux_dir_path);

Copilot uses AI. Check for mistakes.
Comment on lines +648 to +649
QString original_path = QString("/home/orin/roboracer_ws/tmux/%1/.tmuxinator.yaml").arg(QString::fromStdString(config_name));

Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute path /home/orin/roboracer_ws/tmux reduces portability. Consider making this path configurable or using environment variables.

Suggested change
QString original_path = QString("/home/orin/roboracer_ws/tmux/%1/.tmuxinator.yaml").arg(QString::fromStdString(config_name));
// Use environment variable ROBORACER_WS for workspace path
QByteArray ws_path = qgetenv("ROBORACER_WS");
if (ws_path.isEmpty()) {
// Environment variable not set, fallback to default or return error
ws_path = "/home/orin/roboracer_ws";
}
QString original_path = QString("%1/tmux/%2/.tmuxinator.yaml")
.arg(QString::fromUtf8(ws_path))
.arg(QString::fromStdString(config_name));

Copilot uses AI. Check for mistakes.
print('No joystick found!')
print('Please connect a joystick and try again.')
print('If your joystick is connected, ensure that the udev rules are set up correctly.')
print('You can run the script "src/ut_automata/scripts/udev.sh" to set up the appropriate rule.')
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded path reference src/ut_automata/scripts/udev.sh may not be accurate depending on where the package is installed. Consider using a more generic instruction or dynamically resolving the script location.

Suggested change
print('You can run the script "src/ut_automata/scripts/udev.sh" to set up the appropriate rule.')
print('You can run the "udev.sh" script in your package\'s scripts directory to set up the appropriate rule.')

Copilot uses AI. Check for mistakes.
CMakeLists.txt Outdated
add_custom_command(
OUTPUT ${GENERATED_CAR_LUA}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/config
COMMAND /bin/sh -c "hn=$(hostname); num=$(echo \"${hn}\" | grep -oE '[0-9]+' | tail -n1); if [ -z \"${num}\" ]; then num=0; fi; printf 'car_name = \"car%s\";\\n' \"${num}\" > \"${GENERATED_CAR_LUA}\""
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complex shell command embedded in CMakeLists.txt is difficult to read and maintain. Consider extracting this logic into a separate script file for better maintainability.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants