diff --git a/src/wt-assign1-2025-4-parol6-static-pkg/meshes/game.stl b/src/wt-assign1-2025-4-parol6-static-pkg/meshes/game.stl new file mode 100644 index 0000000..c38d767 Binary files /dev/null and b/src/wt-assign1-2025-4-parol6-static-pkg/meshes/game.stl differ diff --git a/src/wt-assign1-2025-4-parol6-static-pkg/urdf/game_board.urdf b/src/wt-assign1-2025-4-parol6-static-pkg/urdf/game_board.urdf new file mode 100644 index 0000000..aa9782c --- /dev/null +++ b/src/wt-assign1-2025-4-parol6-static-pkg/urdf/game_board.urdf @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wt-assign1-2025-4-parol6-static-pkg/urdf/robot_with_game.urdf.xacro b/src/wt-assign1-2025-4-parol6-static-pkg/urdf/robot_with_game.urdf.xacro new file mode 100644 index 0000000..1460a30 --- /dev/null +++ b/src/wt-assign1-2025-4-parol6-static-pkg/urdf/robot_with_game.urdf.xacro @@ -0,0 +1,5 @@ + + + + + diff --git a/src/wt-assign3-2025-5-joint-state-publisher-pkg/launch/inverse_kinematic.launch.xml b/src/wt-assign3-2025-5-joint-state-publisher-pkg/launch/inverse_kinematic.launch.xml index 83faae9..4d2d188 100644 --- a/src/wt-assign3-2025-5-joint-state-publisher-pkg/launch/inverse_kinematic.launch.xml +++ b/src/wt-assign3-2025-5-joint-state-publisher-pkg/launch/inverse_kinematic.launch.xml @@ -1,23 +1,27 @@ - + - - - - - - + + + + + + + + - - - - + + + + + + diff --git a/src/wt-assign3-2025-5-joint-state-publisher-pkg/src/InverseKinematicNode.cpp b/src/wt-assign3-2025-5-joint-state-publisher-pkg/src/InverseKinematicNode.cpp index f5ade31..1648782 100644 --- a/src/wt-assign3-2025-5-joint-state-publisher-pkg/src/InverseKinematicNode.cpp +++ b/src/wt-assign3-2025-5-joint-state-publisher-pkg/src/InverseKinematicNode.cpp @@ -17,9 +17,14 @@ public: a5_ = this->declare_parameter("a5", 0.17635); // Elbow to wrist a6_ = this->declare_parameter("a6", 0.06280); // Wrist offset a7_ = this->declare_parameter("a7", 0.04525); // End effector length - target_x_ = this->declare_parameter("target_x", 0.0); - target_y_ = this->declare_parameter("target_y", 0.0); - target_z_ = this->declare_parameter("target_z", 0.0); + + // Connect 4 board parameters + cell_column_ = this->declare_parameter("cell_column", -1); // -1 = auto-cycle + cell_row_ = this->declare_parameter("cell_row", -1); // -1 = auto-cycle + board_x_ = this->declare_parameter("board_x", 0.25); + board_y_ = this->declare_parameter("board_y", 0.0); + board_z_ = this->declare_parameter("board_z", 0.15); + cell_spacing_ = this->declare_parameter("cell_spacing", 0.025); case_number_ = this->declare_parameter("case_number", 0); calculateInverseKinematics(case_number_); @@ -36,17 +41,37 @@ public: // std::bind(&JointPublisherNode::parametersCallback, this, std::placeholders::_1) // ); - double angle = 0.0; + int current_col = 0; + int current_row = 0; + bool auto_cycle = (cell_column_ == -1 || cell_row_ == -1); + while(true) { - angle += 0.01; - // Vary radius from 0.1 to 0.35 to cover full range (close to far) - double radius = 0.1 + 0.25 * (0.5 + 0.5 * std::sin(angle * 0.3)); - target_x_ = radius * std::cos(angle); - target_y_ = radius * std::sin(angle); - target_z_ = 0.15 + 0.1 * std::sin(angle * 2); + // Use specific cell or auto-cycle through all cells + int col = auto_cycle ? current_col : cell_column_; + int row = auto_cycle ? current_row : cell_row_; + + // Clamp values to valid range + col = std::max(0, std::min(6, col)); + row = std::max(0, std::min(5, row)); + + // Calculate position for current cell (ready to drop coin) + // Board rotated 90 degrees: columns are along Y axis, rows along Z axis + // Position above top of column for coin drop + target_x_ = board_x_; // Fixed distance from robot + target_y_ = board_y_ + (col - 3) * cell_spacing_; // Column position (left to right) + target_z_ = board_z_ + 0.1; // Above the board to drop coins + calculateInverseKinematics(case_number_); broadcastJointState(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + + // Move to next column only in auto-cycle mode (cycle through columns, not all cells) + if (auto_cycle) { + current_col++; + if (current_col >= 7) { + current_col = 0; + } + } } RCLCPP_INFO(this->get_logger(), @@ -80,6 +105,14 @@ private: double a5_; // Elbow to wrist (176.35mm) double a6_; // Wrist offset (62.8mm) double a7_; // End effector length (45.25mm) + + // Connect 4 board parameters + int cell_column_; + int cell_row_; + double board_x_; + double board_y_; + double board_z_; + double cell_spacing_; int case_number_; double theta_1_;