SMACC
Loading...
Searching...
No Matches
cb_navigate_forward.cpp
Go to the documentation of this file.
3
4namespace cl_move_base_z
5{
6using namespace ::cl_move_base_z::odom_tracker;
7
9{
10 this->forwardDistance = forwardDistance;
11}
12
14{
15}
16
18{
19 // straight motion distance
20 double dist;
21
22 if (!forwardDistance)
23 {
24 this->getCurrentState()->param("straight_motion_distance", dist, 3.5);
25 }
26 else
27 {
28 dist = *forwardDistance;
29 }
30
31 ROS_INFO_STREAM("[CbNavigateForward] Straight motion distance: " << dist);
32
34 auto referenceFrame = p->getReferenceFrame();
35 auto currentPoseMsg = p->toPoseMsg();
36
38 {
39 currentPoseMsg.orientation = *forceInitialOrientation;
40 ROS_WARN_STREAM("[CbNavigateForward] Forcing initial straight motion orientation: " << currentPoseMsg.orientation);
41 }
42
43 tf::Transform currentPose;
44 tf::poseMsgToTF(currentPoseMsg, currentPose);
45
46 tf::Transform forwardDeltaTransform;
47 forwardDeltaTransform.setIdentity();
48 forwardDeltaTransform.setOrigin(tf::Vector3(dist, 0, 0));
49
50 tf::Transform targetPose = currentPose * forwardDeltaTransform;
51
52 ClMoveBaseZ::Goal goal;
53 goal.target_pose.header.frame_id = referenceFrame;
54 goal.target_pose.header.stamp = ros::Time::now();
55 tf::poseTFToMsg(targetPose, goal.target_pose.pose);
56
57 ROS_INFO_STREAM("TARGET POSE FORWARD: " << goal.target_pose.pose);
58
59 geometry_msgs::PoseStamped currentStampedPoseMsg;
60 currentStampedPoseMsg.header.frame_id = referenceFrame;
61 currentStampedPoseMsg.header.stamp = ros::Time::now();
62 tf::poseTFToMsg(currentPose, currentStampedPoseMsg.pose);
63
65 odomTracker_->pushPath("StraightNavigationForwards");
66
67 odomTracker_->setStartPoint(currentStampedPoseMsg);
68 odomTracker_->setWorkingMode(WorkingMode::RECORD_PATH);
69
70 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
71 plannerSwitcher->setForwardPlanner();
72
74}
75
77{
78 this->odomTracker_->setWorkingMode(WorkingMode::IDLE);
79}
80
81} // namespace cl_move_base_z
boost::optional< float > forwardDistance
odom_tracker::OdomTracker * odomTracker_
boost::optional< geometry_msgs::Quaternion > forceInitialOrientation
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39
void setStartPoint(const geometry_msgs::PoseStamped &pose)
void pushPath(std::string newPathTagName="")
void setWorkingMode(WorkingMode workingMode)
TComponent * getComponent()
bool param(std::string param_name, T &param_val, const T &default_val) const