Skip to content

Commit

Permalink
Change format
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwoo authored and yunwoo committed May 18, 2024
1 parent 2e5dec2 commit b565a75
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
15 changes: 6 additions & 9 deletions larr_planner/include/larr_planner/type_manager/TypeManager.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@


namespace larr_planner{
struct Position{
namespace larr_planner {
struct Position {
double px;
double py;
double pz;
};
struct Quaternion{
struct Quaternion {
double qx;
double qy;
double qz;
double qw;
};
struct RobotState {
double t_sec{0.0};
Position pos{0.0,0.0,0.0};
Quaternion orientation{0.0,0.0,0.0,1.0};

Position pos{0.0, 0.0, 0.0};
Quaternion orientation{0.0, 0.0, 0.0, 1.0};
};



}
} // namespace larr_planner
9 changes: 4 additions & 5 deletions larr_planner/include/larr_planner/wrapper/Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@

#include "larr_planner/type_manager/TypeManager.h"

namespace larr_planner{
namespace larr_planner {

class Wrapper{
class Wrapper {
public:
void SetRobotState(const RobotState &robot_state);
private:

private:
};

}

} // namespace larr_planner

#endif // LARR_PLANNER_WRAPPER_H
2 changes: 0 additions & 2 deletions larr_planner/src/type_manager/TypeManager.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#include "larr_planner/type_manager/TypeManager.h"


4 changes: 1 addition & 3 deletions larr_planner/src/wrapper/Wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
// Created by larr on 24. 5. 17.
//
#include "larr_planner/wrapper/Wrapper.h"
void larr_planner::Wrapper::SetRobotState(const larr_planner::RobotState &robot_state) {

}
void larr_planner::Wrapper::SetRobotState(const larr_planner::RobotState &robot_state) {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@

// #include <pcl/PCLPointCloud2.h>
// #include <pcl_conversions/pcl_conversions.h>
#include <rclcpp/rclcpp.hpp>
#include <larr_planner/wrapper/Wrapper.h>
#include <geometry_msgs/msg/pose_stamped.hpp>
#include <larr_planner/wrapper/Wrapper.h>
#include <rclcpp/rclcpp.hpp>
#include <visualization_msgs/msg/marker_array.hpp>

using RobotStateMsg = geometry_msgs::msg::PoseStamped;
using StateSubscriber = rclcpp::Subscription<RobotStateMsg>::SharedPtr;


namespace larr_planner {


class PlanningServer : public rclcpp::Node {
private:
Wrapper *wrapper_ptr_;
Expand All @@ -27,7 +25,6 @@ class PlanningServer : public rclcpp::Node {
void RobotStateCallback(const RobotStateMsg::ConstSharedPtr &msg);
RobotState ConvertToRobotState(const RobotStateMsg &state_msg);


public:
PlanningServer(const rclcpp::NodeOptions &options_input);
};
Expand Down
6 changes: 3 additions & 3 deletions larr_planner_ros2/src/planning_server/planning_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ PlanningServer::PlanningServer(const rclcpp::NodeOptions &options_input) : Node(
// Subscribe Robot State {POSITION, ORIENTATION}
options.callback_group = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
state_subscriber_ = create_subscription<RobotStateMsg>(
"~/state", rclcpp::QoS(1), std::bind(&PlanningServer::RobotStateCallback,this, std::placeholders::_1),options);
"~/state", rclcpp::QoS(1), std::bind(&PlanningServer::RobotStateCallback, this, std::placeholders::_1), options);
}

void PlanningServer::RobotStateCallback(const geometry_msgs::msg::PoseStamped::ConstSharedPtr &msg) {
wrapper_ptr_-> SetRobotState(ConvertToRobotState(*msg));
wrapper_ptr_->SetRobotState(ConvertToRobotState(*msg));
}

RobotState PlanningServer::ConvertToRobotState(const RobotStateMsg &state_msg) {
RobotState state;
state.t_sec = state_msg.header.stamp.sec + state_msg.header.stamp.nanosec*1E-9;
state.t_sec = state_msg.header.stamp.sec + state_msg.header.stamp.nanosec * 1E-9;
state.pos.px = state_msg.pose.position.x;
state.pos.py = state_msg.pose.position.y;
state.pos.pz = state_msg.pose.position.z;
Expand Down

0 comments on commit b565a75

Please sign in to comment.