SMACC
Loading...
Searching...
No Matches
cb_rotate.cpp
Go to the documentation of this file.
4
5namespace cl_move_base_z
6{
8{
9}
10
11CbRotate::CbRotate(float rotate_degree)
12{
13 rotateDegree = rotate_degree;
14}
15
17{
18 double angle_increment_degree;
19
20 if (!rotateDegree)
21 {
22 this->getCurrentState()->param("angle_increment_degree", angle_increment_degree, 45.0);
23 }
24 else
25 {
26 angle_increment_degree = *rotateDegree;
27 }
28
29 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
30 // this should work better with a coroutine and await
31 // this->plannerSwitcher_->setForwardPlanner();
32 plannerSwitcher->setDefaultPlanners();
33
35 auto referenceFrame = p->getReferenceFrame();
36 auto currentPoseMsg = p->toPoseMsg();
37
38 tf::Transform currentPose;
39 tf::poseMsgToTF(currentPoseMsg, currentPose);
40
42 ClMoveBaseZ::Goal goal;
43 goal.target_pose.header.frame_id = referenceFrame;
44 goal.target_pose.header.stamp = ros::Time::now();
45
46 auto currentAngle = tf::getYaw(currentPoseMsg.orientation);
47 auto targetAngle = currentAngle + angle_increment_degree * M_PI / 180.0;
48 goal.target_pose.pose.position = currentPoseMsg.position;
49 goal.target_pose.pose.orientation = tf::createQuaternionMsgFromYaw(targetAngle);
50
51 geometry_msgs::PoseStamped stampedCurrentPoseMsg;
52 stampedCurrentPoseMsg.header.frame_id = referenceFrame;
53 stampedCurrentPoseMsg.header.stamp = ros::Time::now();
54 stampedCurrentPoseMsg.pose = currentPoseMsg;
55
57 odomTracker->pushPath("RelativeRotation");
58
59 odomTracker->setStartPoint(stampedCurrentPoseMsg);
60 odomTracker->setWorkingMode(odom_tracker::WorkingMode::RECORD_PATH);
61
62 ROS_INFO_STREAM("current pose: " << currentPoseMsg);
63 ROS_INFO_STREAM("goal pose: " << goal.target_pose.pose);
65}
66
67} // namespace cl_move_base_z
virtual void onEntry() override
Definition: cb_rotate.cpp:16
boost::optional< float > rotateDegree
Definition: cb_rotate.h:18
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39
This class track the required distance of the cord based on the external localization system.
Definition: odom_tracker.h:47
void requiresClient(SmaccClientType *&storage)
TComponent * getComponent()
bool param(std::string param_name, T &param_val, const T &default_val) const