Skip to content

Commit

Permalink
linter reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
meshvaD committed Jan 21, 2023
1 parent a137977 commit 3778e61
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,50 +1,22 @@
// #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"

// namespace uwrt_motion_planning {

// class MotionPlanClient : public rclcpp::Node {
// public:
// UWRT_MOTION_PLANNING_PUBLIC
// explicit MotionPlanClient(const rclcpp::NodeOptions& options);
// private:
// // rclcpp::Client<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>::SharedPtr client;
// rclcpp::Client<example_interfaces::srv::AddTwoInts>::SharedPtr client;
// rclcpp::TimerBase::SharedPtr timer;

// void on_timer();

// };
// }

// #endif

#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
{
public:
explicit MotionPlanClient(const rclcpp::NodeOptions & options);
namespace uwrt_motion_planning {
class MotionPlanClient : public rclcpp::Node {
public:
explicit MotionPlanClient(const rclcpp::NodeOptions& options);

protected:
protected:
void execute();

private:
private:
rclcpp::Client<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>::SharedPtr client_;
};

}
} // namespace uwrt_motion_planning

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

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

#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>

namespace uwrt_motion_planning
{
#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"

class MotionPlanServer : public rclcpp::Node
{
public:
UWRT_MOTION_PLANNING_PUBLIC
explicit MotionPlanServer(const rclcpp::NodeOptions & options);
namespace uwrt_motion_planning {

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);
class MotionPlanServer : public rclcpp::Node {
public:
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);
};

}
} // namespace uwrt_motion_planning

#endif

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

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

using namespace std::chrono_literals;

namespace uwrt_motion_planning
{
namespace uwrt_motion_planning {

MotionPlanClient::MotionPlanClient(const rclcpp::NodeOptions & options)
: Node("Client", options)
{
MotionPlanClient::MotionPlanClient(const rclcpp::NodeOptions& options) : Node("Client", options) {
client_ = create_client<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>("motion_plan");

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 @@ -42,15 +36,14 @@ 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 @@ -6,42 +6,36 @@

#include "rclcpp/rclcpp.hpp"

namespace uwrt_motion_planning
{

MotionPlanServer::MotionPlanServer(const rclcpp::NodeOptions & options)
: Node("Server", options)
{
srv_ = create_service<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>("motion_plan",
std::bind(&MotionPlanServer::solve_ik, this, std::placeholders::_1, std::placeholders::_2));
namespace uwrt_motion_planning {

MotionPlanServer::MotionPlanServer(const rclcpp::NodeOptions& options) : Node("Server", options) {
srv_ = create_service<uwrt_mars_rover_arm_urdf_moveit::srv::MotionPlan>(
"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 composition
} // namespace uwrt_motion_planning

#include "rclcpp_components/register_node_macro.hpp"
RCLCPP_COMPONENTS_REGISTER_NODE(uwrt_motion_planning::MotionPlanServer)
12 changes: 0 additions & 12 deletions uwrt_mars_rover_arm/uwrt_mars_rover_arm_hw/compile_commands.json

This file was deleted.

0 comments on commit 3778e61

Please sign in to comment.