Skip to content

Commit

Permalink
Revert "linter reformatting"
Browse files Browse the repository at this point in the history
This reverts commit 3778e61.
  • Loading branch information
meshvaD committed Feb 9, 2023
1 parent bb9ecef commit 71e3539
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef MOTION_PLAN_CLIENT_H
#define MOTION_PLAN_CLIENT_H

#include "rclcpp/rclcpp.hpp"
#include "uwrt_mars_rover_arm_urdf_moveit/srv/motion_plan.hpp"
#include "uwrt_mars_rover_arm_urdf_moveit/visibility_control.hpp"
#include "example_interfaces/srv/add_two_ints.hpp"
#include "rclcpp/rclcpp.hpp"

namespace uwrt_motion_planning {
class MotionPlanClient : public rclcpp::Node {
Expand All @@ -16,6 +17,6 @@ class MotionPlanClient : public rclcpp::Node {
void execute();
};

} // namespace uwrt_motion_planning
}

#endif
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef MOTION_PLAN_SERVER_H
#define MOTION_PLAN_SERVER_H

#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/robot_model/robot_model.h>
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <moveit/robot_state/robot_state.h>
#include <moveit/move_group_interface/move_group_interface.h>

#include "rclcpp/rclcpp.hpp"
#include "uwrt_mars_rover_arm_urdf_moveit/srv/motion_plan.hpp"
Expand All @@ -16,12 +16,13 @@ class MotionPlanServer : public rclcpp::Node {
UWRT_MOTION_PLANNING_PUBLIC
explicit MotionPlanServer(const rclcpp::NodeOptions& options);

private:
rclcpp::Service<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>::SharedPtr srv_;
void solve_ik(const std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Request> request,
std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Response> response);
private:
rclcpp::Service<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>::SharedPtr srv_;
void solve_ik(const std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Request> request,
std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Response> response);
};

} // namespace uwrt_motion_planning
}

#endif

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <iostream>
#include <memory>

#include "geometry_msgs/msg/pose.hpp"
#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/pose.hpp"

using namespace std::chrono_literals;

Expand All @@ -16,10 +16,13 @@ MotionPlanClient::MotionPlanClient(const rclcpp::NodeOptions& options) : Node("C
execute();
}

void MotionPlanClient::execute() {
void MotionPlanClient::execute()
{
if (!client_->wait_for_service(1s)) {
if (!rclcpp::ok()) {
RCLCPP_ERROR(this->get_logger(), "Interrupted while waiting for the service. Exiting.");
RCLCPP_ERROR(
this->get_logger(),
"Interrupted while waiting for the service. Exiting.");
return;
}
RCLCPP_INFO(this->get_logger(), "Service not available after waiting");
Expand All @@ -35,14 +38,15 @@ void MotionPlanClient::execute() {
auto request = std::make_shared<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Request>();
request->pose = target;

using ServiceResponseFuture = rclcpp::Client<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>::SharedFuture;
using ServiceResponseFuture =
rclcpp::Client<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>::SharedFuture;
auto response_received_callback = [this](ServiceResponseFuture future) {
RCLCPP_INFO(this->get_logger(), "Got result: [%d]", future.get()->success);
};
RCLCPP_INFO(this->get_logger(), "Got result: [%d]", future.get()->success);
};
auto future_result = client_->async_send_request(request, response_received_callback);
}

} // namespace uwrt_motion_planning
}

#include "rclcpp_components/register_node_macro.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,32 @@ MotionPlanServer::MotionPlanServer(const rclcpp::NodeOptions& options) : Node("S
"motion_plan", std::bind(&MotionPlanServer::solve_ik, this, std::placeholders::_1, std::placeholders::_2));
}

void MotionPlanServer::solve_ik(
const std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Request> request,
std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Response> response) {
void MotionPlanServer::solve_ik(const std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Request> request,
std::shared_ptr<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan::Response> response)
{
RCLCPP_INFO(this->get_logger(), "Incoming request");
std::flush(std::cout);

// set move_group that we are planning for
//set move_group that we are planning for
static const std::string PLANNING_GROUP = "uwrt_arm";
moveit::planning_interface::MoveGroupInterface move_group(this->shared_from_this(), PLANNING_GROUP);

move_group.setPoseTarget(request->pose);

moveit::planning_interface::MoveGroupInterface::Plan my_plan;

// try planning to point and record success/failure
//try planning to point and record success/failure
bool success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
RCLCPP_INFO(this->get_logger(), "Visualizing plan 1 (pose goal) %s", success ? "" : "FAILED");

// move to position if planning is successful
//move to position if planning is successful
response->success = success;
if (success) move_group.move();
if (success)
move_group.move();

}

} // namespace uwrt_motion_planning
} // namespace composition

#include "rclcpp_components/register_node_macro.hpp"
RCLCPP_COMPONENTS_REGISTER_NODE(uwrt_motion_planning::MotionPlanServer)

This file was deleted.

12 changes: 12 additions & 0 deletions uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/compile_commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"directory": "/home/keyon/excode/uwrt_rover/build/uwrt_mars_rover_arm_hw",
"command": "/usr/bin/c++ -DDEFAULT_RMW_IMPLEMENTATION=rmw_cyclonedds_cpp -DRCUTILS_ENABLE_FAULT_INJECTION -DUWRT_MARS_ROVER_ARM_HW_DLL -Duwrt_mars_rover_arm_hw_EXPORTS -I/home/keyon/excode/uwrt_rover/src/uwrt_mars_rover/uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/include -isystem /opt/ros/galactic/include -fPIC -Wall -Wextra -Wpedantic -Wshadow -Werror -std=gnu++17 -o CMakeFiles/uwrt_mars_rover_arm_hw.dir/src/uwrt_mars_rover_arm_hw_actuator.cpp.o -c /home/keyon/excode/uwrt_rover/src/uwrt_mars_rover/uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/src/uwrt_mars_rover_arm_hw_actuator.cpp",
"file": "/home/keyon/excode/uwrt_rover/src/uwrt_mars_rover/uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/src/uwrt_mars_rover_arm_hw_actuator.cpp"
},
{
"directory": "/home/keyon/excode/uwrt_rover/build/uwrt_mars_rover_arm_hw",
"command": "/usr/bin/c++ -DDEFAULT_RMW_IMPLEMENTATION=rmw_cyclonedds_cpp -DRCUTILS_ENABLE_FAULT_INJECTION -DUWRT_MARS_ROVER_ARM_HW_DLL -Duwrt_mars_rover_arm_hw_EXPORTS -I/home/keyon/excode/uwrt_rover/src/uwrt_mars_rover/uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/include -isystem /opt/ros/galactic/include -fPIC -Wall -Wextra -Wpedantic -Wshadow -Werror -std=gnu++17 -o CMakeFiles/uwrt_mars_rover_arm_hw.dir/src/uwrt_mars_rover_arm_hw_differential.cpp.o -c /home/keyon/excode/uwrt_rover/src/uwrt_mars_rover/uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/src/uwrt_mars_rover_arm_hw_differential.cpp",
"file": "/home/keyon/excode/uwrt_rover/src/uwrt_mars_rover/uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/src/uwrt_mars_rover_arm_hw_differential.cpp"
}
]

0 comments on commit 71e3539

Please sign in to comment.