SMACC
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
cl_move_base_z::CbAbsoluteRotate Class Reference

#include <cb_absolute_rotate.h>

Inheritance diagram for cl_move_base_z::CbAbsoluteRotate:
Inheritance graph
Collaboration diagram for cl_move_base_z::CbAbsoluteRotate:
Collaboration graph

Public Member Functions

 CbAbsoluteRotate ()
 
 CbAbsoluteRotate (float absoluteGoalAngleDegree, float yawGoalTolerance=-1)
 
virtual void onEntry () override
 
virtual void onExit () override
 
- Public Member Functions inherited from cl_move_base_z::CbMoveBaseClientBehaviorBase
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
- Public Member Functions inherited from smacc::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
boost::signals2::connection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFailure (TCallback callback, T *object)
 
- Public Member Functions inherited from smacc::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage)
 
ros::NodeHandle getNode ()
 

Public Attributes

tf::TransformListener listener
 
boost::optional< float > absoluteGoalAngleDegree
 
boost::optional< float > yawGoalTolerance
 
boost::optional< float > maxVelTheta
 
boost::optional< SpiningPlannerspinningPlanner
 

Private Member Functions

void updateTemporalBehaviorParameters (bool undo)
 

Private Attributes

float oldYawTolerance
 
float oldMaxVelTheta
 
float oldMinVelTheta
 

Additional Inherited Members

- Protected Member Functions inherited from smacc::SmaccAsyncClientBehavior
virtual void executeOnEntry () override
 
virtual void executeOnExit () override
 
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
- Protected Member Functions inherited from smacc::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
virtual void onEntry ()
 
virtual void onExit ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 
virtual void dispose ()
 
- Protected Attributes inherited from cl_move_base_z::CbMoveBaseClientBehaviorBase
ClMoveBaseZmoveBaseClient_
 
ros::Publisher visualizationMarkersPub_
 

Detailed Description

Definition at line 21 of file cb_absolute_rotate.h.

Constructor & Destructor Documentation

◆ CbAbsoluteRotate() [1/2]

cl_move_base_z::CbAbsoluteRotate::CbAbsoluteRotate ( )

Definition at line 8 of file cb_absolute_rotate.cpp.

9{
10}

◆ CbAbsoluteRotate() [2/2]

cl_move_base_z::CbAbsoluteRotate::CbAbsoluteRotate ( float  absoluteGoalAngleDegree,
float  yawGoalTolerance = -1 
)

Definition at line 12 of file cb_absolute_rotate.cpp.

13{
15
16 if (yaw_goal_tolerance >= 0)
17 {
18 this->yawGoalTolerance = yaw_goal_tolerance;
19 }
20}
boost::optional< float > yawGoalTolerance
boost::optional< float > absoluteGoalAngleDegree

References absoluteGoalAngleDegree, and yawGoalTolerance.

Member Function Documentation

◆ onEntry()

void cl_move_base_z::CbAbsoluteRotate::onEntry ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 137 of file cb_absolute_rotate.cpp.

138{
139 double goal_angle;
140 ROS_INFO_STREAM("[CbAbsoluteRotate] Absolute yaw Angle:" << this->absoluteGoalAngleDegree);
141
142 if (!this->absoluteGoalAngleDegree)
143 {
144 this->getCurrentState()->param("goal_angle", goal_angle, 45.0);
145 }
146 else
147 {
148 goal_angle = *this->absoluteGoalAngleDegree;
149 }
150
151 auto plannerSwitcher = moveBaseClient_->getComponent<PlannerSwitcher>();
152 // this should work better with a coroutine and await
153 // this->plannerSwitcher_->setForwardPlanner();
154
156 plannerSwitcher->setPureSpinningPlanner();
157 else
158 plannerSwitcher->setDefaultPlanners();
159
161
163 auto referenceFrame = p->getReferenceFrame();
164 auto currentPoseMsg = p->toPoseMsg();
165
166 ClMoveBaseZ::Goal goal;
167 goal.target_pose.header.frame_id = referenceFrame;
168 goal.target_pose.header.stamp = ros::Time::now();
169
170 auto currentAngle = tf::getYaw(currentPoseMsg.orientation);
171 auto targetAngle = goal_angle * M_PI / 180.0;
172 goal.target_pose.pose.position = currentPoseMsg.position;
173 goal.target_pose.pose.orientation = tf::createQuaternionMsgFromYaw(targetAngle);
174
175 auto odomTracker_ = moveBaseClient_->getComponent<odom_tracker::OdomTracker>();
176 if (odomTracker_ != nullptr)
177 {
178 odomTracker_->pushPath("PureSpinningToAbsoluteGoalOrientation");
179 odomTracker_->setStartPoint(p->toPoseStampedMsg());
180 odomTracker_->setWorkingMode(odom_tracker::WorkingMode::RECORD_PATH);
181 }
182
183 ROS_INFO_STREAM("[CbAbsoluteRotate] current pose: " << currentPoseMsg);
184 ROS_INFO_STREAM("[CbAbsoluteRotate] goal pose: " << goal.target_pose.pose);
186}
boost::optional< SpiningPlanner > spinningPlanner
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39
TComponent * getComponent()
bool param(std::string param_name, T &param_val, const T &default_val) const

References absoluteGoalAngleDegree, smacc::ISmaccClient::getComponent(), smacc::ISmaccClientBehavior::getCurrentState(), cl_move_base_z::Pose::getReferenceFrame(), cl_move_base_z::CbMoveBaseClientBehaviorBase::moveBaseClient_, smacc::ISmaccState::param(), cl_move_base_z::PureSpinning, cl_move_base_z::odom_tracker::OdomTracker::pushPath(), cl_move_base_z::odom_tracker::RECORD_PATH, smacc::client_bases::SmaccActionClientBase< ActionType >::sendGoal(), cl_move_base_z::PlannerSwitcher::setPureSpinningPlanner(), spinningPlanner, and updateTemporalBehaviorParameters().

Here is the call graph for this function:

◆ onExit()

void cl_move_base_z::CbAbsoluteRotate::onExit ( )
overridevirtual

Reimplemented from smacc::ISmaccClientBehavior.

Definition at line 125 of file cb_absolute_rotate.cpp.

126{
128 {
129 }
130 else
131 {
132 }
133
135}

References cl_move_base_z::PureSpinning, spinningPlanner, and updateTemporalBehaviorParameters().

Here is the call graph for this function:

◆ updateTemporalBehaviorParameters()

void cl_move_base_z::CbAbsoluteRotate::updateTemporalBehaviorParameters ( bool  undo)
private

Definition at line 22 of file cb_absolute_rotate.cpp.

23{
24 dynamic_reconfigure::ReconfigureRequest srv_req;
25 dynamic_reconfigure::ReconfigureResponse srv_resp;
26 dynamic_reconfigure::Config conf;
27
28 ros::NodeHandle nh;
29 std::string nodename = "/move_base";
30 std::string localPlannerName;
31 dynamic_reconfigure::DoubleParameter yaw_goal_tolerance;
32 yaw_goal_tolerance.name = "yaw_goal_tolerance";
33
34 dynamic_reconfigure::DoubleParameter max_vel_theta;
35 dynamic_reconfigure::DoubleParameter min_vel_theta;
36 bool isRosBasePlanner = !spinningPlanner || *spinningPlanner == SpiningPlanner::Default;
37 bool isPureSpinningPlanner = spinningPlanner && *spinningPlanner == SpiningPlanner::PureSpinning;
38
39 if (isPureSpinningPlanner)
40 {
41 localPlannerName = "PureSpinningLocalPlanner";
42 max_vel_theta.name = "max_angular_z_speed";
43 min_vel_theta.name = "min_vel_theta";
44 }
45 else if (isRosBasePlanner)
46 {
47 localPlannerName = "TrajectoryPlannerROS";
48 max_vel_theta.name = "max_vel_theta";
49 min_vel_theta.name = "min_vel_theta";
50 }
51
52 if (!undo)
53 {
55 {
56 // save old yaw tolerance
57 nh.getParam(nodename + "/" + localPlannerName + "/yaw_goal_tolerance", oldYawTolerance);
58 yaw_goal_tolerance.value = *yawGoalTolerance;
59 conf.doubles.push_back(yaw_goal_tolerance);
60 ROS_INFO("[CbAbsoluteRotate] updating yaw tolerance local planner to: %lf, from previous value: %lf ",
62 }
63
64 if (maxVelTheta)
65 {
66 if (isRosBasePlanner)
67 {
68 // save old yaw tolerance
69 // nh.getParam(nodename + "/" + localPlannerName+"/min_vel_theta", oldMinVelTheta);
70 nh.getParam(nodename + "/" + localPlannerName + "/max_vel_theta", oldMaxVelTheta);
71 }
72 max_vel_theta.value = *maxVelTheta;
73 min_vel_theta.value = -*maxVelTheta;
74 conf.doubles.push_back(max_vel_theta);
75 conf.doubles.push_back(min_vel_theta);
76 ROS_INFO("[CbAbsoluteRotate] updating max vel theta local planner to: %lf, from previous value: %lf ",
78 ROS_INFO("[CbAbsoluteRotate] updating min vel theta local planner to: %lf, from previous value: %lf ",
80 }
81 }
82 else
83 {
85 {
86 yaw_goal_tolerance.value = oldYawTolerance;
87 conf.doubles.push_back(yaw_goal_tolerance);
88 ROS_INFO("[CbAbsoluteRotate] restoring yaw tolerance local planner from: %lf, to previous value: %lf ",
90 }
91
92 if (maxVelTheta)
93 {
94 if (isRosBasePlanner)
95 {
96 max_vel_theta.value = oldMaxVelTheta;
97 min_vel_theta.value = oldMinVelTheta;
98 }
99
100 conf.doubles.push_back(max_vel_theta);
101 conf.doubles.push_back(min_vel_theta);
102 ROS_INFO("[CbAbsoluteRotate] restoring max vel theta local planner from: %lf, to previous value: %lf ",
104 ROS_INFO("[CbAbsoluteRotate] restoring min vel theta local planner from: %lf, to previous value: %lf ",
105 -(*maxVelTheta), this->oldMinVelTheta);
106 }
107 }
108
109 srv_req.config = conf;
110 bool res;
111 do
112 {
113 std::string servername = nodename + "/" + localPlannerName + "/set_parameters";
114 res = ros::service::call(servername, srv_req, srv_resp);
115 ROS_INFO_STREAM("[CbAbsoluteRotate] dynamic configure call [" << servername << "]: " << res);
116 ros::spinOnce();
117 if (!res)
118 {
119 ros::Duration(0.1).sleep();
120 ROS_INFO("[CbAbsoluteRotate] Failed, retrtying call");
121 }
122 } while (!res);
123}
boost::optional< float > maxVelTheta

References cl_move_base_z::Default, maxVelTheta, oldMaxVelTheta, oldMinVelTheta, oldYawTolerance, cl_move_base_z::PureSpinning, spinningPlanner, and yawGoalTolerance.

Referenced by onEntry(), and onExit().

Here is the caller graph for this function:

Member Data Documentation

◆ absoluteGoalAngleDegree

boost::optional<float> cl_move_base_z::CbAbsoluteRotate::absoluteGoalAngleDegree

Definition at line 26 of file cb_absolute_rotate.h.

Referenced by CbAbsoluteRotate(), and onEntry().

◆ listener

tf::TransformListener cl_move_base_z::CbAbsoluteRotate::listener

Definition at line 24 of file cb_absolute_rotate.h.

◆ maxVelTheta

boost::optional<float> cl_move_base_z::CbAbsoluteRotate::maxVelTheta

Definition at line 28 of file cb_absolute_rotate.h.

Referenced by updateTemporalBehaviorParameters().

◆ oldMaxVelTheta

float cl_move_base_z::CbAbsoluteRotate::oldMaxVelTheta
private

Definition at line 41 of file cb_absolute_rotate.h.

Referenced by updateTemporalBehaviorParameters().

◆ oldMinVelTheta

float cl_move_base_z::CbAbsoluteRotate::oldMinVelTheta
private

Definition at line 42 of file cb_absolute_rotate.h.

Referenced by updateTemporalBehaviorParameters().

◆ oldYawTolerance

float cl_move_base_z::CbAbsoluteRotate::oldYawTolerance
private

Definition at line 40 of file cb_absolute_rotate.h.

Referenced by updateTemporalBehaviorParameters().

◆ spinningPlanner

boost::optional<SpiningPlanner> cl_move_base_z::CbAbsoluteRotate::spinningPlanner

Definition at line 29 of file cb_absolute_rotate.h.

Referenced by onEntry(), onExit(), and updateTemporalBehaviorParameters().

◆ yawGoalTolerance

boost::optional<float> cl_move_base_z::CbAbsoluteRotate::yawGoalTolerance

Definition at line 27 of file cb_absolute_rotate.h.

Referenced by CbAbsoluteRotate(), and updateTemporalBehaviorParameters().


The documentation for this class was generated from the following files: