Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #302

Open
wants to merge 49 commits into
base: melodic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
db13aa3
Add files via upload
felix657 May 10, 2021
0f7b793
Delete TebLocalPlannerReconfigure.cfg
felix657 May 10, 2021
e2afff1
Add files via upload
felix657 May 10, 2021
2891285
Delete edge_acceleration.h
felix657 May 10, 2021
e2b06f3
Add files via upload
felix657 May 10, 2021
65beab3
Delete edge_velocity.h
felix657 May 10, 2021
70c802d
Add files via upload
felix657 May 10, 2021
9d2a182
Delete misc.h
felix657 May 10, 2021
b514dc0
Add files via upload
felix657 May 10, 2021
5b9f347
Add files via upload
felix657 May 10, 2021
f8a01f5
Delete teb_config.h
felix657 May 10, 2021
3af7869
Add files via upload
felix657 May 10, 2021
3db0c66
Add files via upload
felix657 May 10, 2021
95527d1
Delete optimal_planner.cpp
felix657 May 10, 2021
ff69984
Add files via upload
felix657 May 10, 2021
cd587b5
Delete teb_config.cpp
felix657 May 10, 2021
ded1c9a
Add files via upload
felix657 May 10, 2021
83beccd
Delete TebLocalPlannerReconfigure.cfg
felix657 May 10, 2021
4772eb2
Delete base_teb_edges.h
felix657 May 10, 2021
2b7e95c
Delete edge_dynamic_obstacle.h
felix657 May 10, 2021
ba573b8
Delete edge_kinematics.h
felix657 May 10, 2021
c734a85
Delete edge_prefer_rotdir.h
felix657 May 10, 2021
d521367
Delete edge_shortest_path.h
felix657 May 10, 2021
701ee94
Delete edge_velocity.h
felix657 May 10, 2021
187859c
Delete edge_velocity_obstacle_ratio.h
felix657 May 10, 2021
02bb9ec
Delete edge_time_optimal.h
felix657 May 10, 2021
4f1b93c
Delete edge_via_point.h
felix657 May 10, 2021
d08fca8
Delete edge_acceleration.h
felix657 May 10, 2021
a1311f0
Delete optimal_planner.cpp
felix657 May 10, 2021
fd7b756
Delete edge_obstacle.h
felix657 May 10, 2021
ee5c9d3
Delete teb_config.cpp
felix657 May 10, 2021
2cfc9b8
Delete penalties.h
felix657 May 10, 2021
de64a77
Delete misc.h
felix657 May 10, 2021
e9dccda
Delete optimal_planner.h
felix657 May 10, 2021
7deda05
Delete vertex_pose.h
felix657 May 10, 2021
1c7e4a8
Delete visualize_vel_and_steering.py
felix657 May 10, 2021
5cdc0d2
Delete vertex_timediff.h
felix657 May 10, 2021
4f350f0
Delete teb_config.h
felix657 May 10, 2021
0928302
Update visualize_vel_and_steering.py
chelseabright96 May 31, 2021
abebee1
Update visualize_vel_and_steering.py
felix657 Jun 1, 2021
bd45df7
Merge pull request #2 from chelseabright96/patch-2
felix657 Jun 8, 2021
11c56d5
Update publish_test_obstacles.py
chelseabright96 Jun 8, 2021
ad1a6fe
Merge pull request #3 from chelseabright96/patch-3
felix657 Jun 14, 2021
73ca5d8
Update visualize_vel_and_steering.py
chelseabright96 Jun 14, 2021
545dfe6
Merge pull request #4 from chelseabright96/patch-4
felix657 Jun 23, 2021
c692266
Delete TebLocalPlannerReconfigure.cfg
felix657 Jun 28, 2021
2e1a5ff
Add files via upload
felix657 Jun 28, 2021
7dad13f
Delete edge_velocity.h
felix657 Jun 28, 2021
394c263
Add files via upload
felix657 Jun 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cfg/TebLocalPlannerReconfigure.cfg
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ grp_robot_carlike.add("min_turning_radius", double_t, 0,
"Minimum turning radius of a carlike robot (diff-drive robot: zero)",
0.0, 0.0, 50.0)

grp_robot_carlike.add("max_steering_rate", double_t, 0,
"EXPERIMENTAL: Maximum steering rate of a carlike robot (THIS SIGNIFICANTLY AFFECTS PERFORMANCE AT THE MOMENT) [deactivate: zero]",
1.5, 1.0, 10.0)

grp_robot_carlike.add("wheelbase", double_t, 0,
"The distance between the drive shaft and steering axle (only required for a carlike robot with 'cmd_angle_instead_rotvel' enabled); The value might be negative for back-wheeled robots!",
1.0, -10.0, 10.0)
Expand Down Expand Up @@ -279,6 +283,10 @@ grp_optimization.add("weight_kinematics_turning_radius", double_t, 0,
"Optimization weight for enforcing a minimum turning radius (carlike robots)",
1, 0, 1000)

grp_optimization.add("weight_max_steering_rate", double_t, 0,
"EXPERIMENTAL: Optimization weight for enforcing a minimum steering rate of a carlike robot (TRY TO KEEP THE WEIGHT LOW OR DEACTIVATE, SINCE IT SIGNIFICANTLY AFFECTS PERFORMANCE AT THE MOMENT)",
0, 0, 1000)

grp_optimization.add("weight_optimaltime", double_t, 0,
"Optimization weight for contracting the trajectory w.r.t. transition time",
1, 0, 1000)
Expand Down
231 changes: 225 additions & 6 deletions include/teb_local_planner/g2o_types/edge_velocity.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class EdgeVelocity : public BaseTebMultiEdge<2, double>
double vel = dist / deltaT->estimate();

// vel *= g2o::sign(deltaS[0]*cos(conf1->theta()) + deltaS[1]*sin(conf1->theta())); // consider direction
vel *= fast_sigmoid( 100 * (deltaS.x()*cos(conf1->theta()) + deltaS.y()*sin(conf1->theta())) ); // consider direction
vel *= fast_sigmoid( 100.0 * (deltaS.x()*cos(conf1->theta()) + deltaS.y()*sin(conf1->theta())) ); // consider direction

const double omega = angle_diff / deltaT->estimate();

Expand Down Expand Up @@ -198,10 +198,6 @@ class EdgeVelocity : public BaseTebMultiEdge<2, double>
};






/**
* @class EdgeVelocityHolonomic
* @brief Edge defining the cost function for limiting the translational and rotational velocity according to x,y and theta.
Expand Down Expand Up @@ -260,13 +256,236 @@ class EdgeVelocityHolonomic : public BaseTebMultiEdge<3, double>
"EdgeVelocityHolonomic::computeError() _error[0]=%f _error[1]=%f _error[2]=%f\n",_error[0],_error[1],_error[2]);
}


public:

EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};


/**
* @class EdgeSteeringRate
* @brief Edge defining the cost function for limiting the steering rate w.r.t. the current wheelbase parameter
*
* The edge depends on four vertices \f$ \mathbf{s}_i, \mathbf{s}_{ip1}, \mathbf{s}_{ip2} \Delta T_i \f$ .
* @remarks This edge requires the TebConfig::Robot::whelbase parameter to be set.
* @remarks Do not forget to call setTebConfig()
*/
class EdgeSteeringRate : public BaseTebMultiEdge<1, double>
{
public:

/**
* @brief Construct edge.
*/
EdgeSteeringRate()
{
this->resize(5); // Since we derive from a g2o::BaseMultiEdge, set the desired number of vertices
}

/**
* @brief Actual cost function
*/
void computeError()
{
ROS_ASSERT_MSG(cfg_, "You must call setTebConfig on EdgeSteeringRate()");
const VertexPose* conf1 = static_cast<const VertexPose*>(_vertices[0]);
const VertexPose* conf2 = static_cast<const VertexPose*>(_vertices[1]);
const VertexPose* conf3 = static_cast<const VertexPose*>(_vertices[2]);
const VertexTimeDiff* dt1 = static_cast<const VertexTimeDiff*>(_vertices[3]);
const VertexTimeDiff* dt2 = static_cast<const VertexTimeDiff*>(_vertices[4]);

Eigen::Vector2d delta_s1 = conf2->estimate().position() - conf1->estimate().position();
Eigen::Vector2d delta_s2 = conf3->estimate().position() - conf2->estimate().position();
double dist1 = delta_s1.norm();
double dist2 = delta_s2.norm();
double angle_diff1 = g2o::normalize_theta( conf2->theta() - conf1->theta() );
double angle_diff2 = g2o::normalize_theta( conf3->theta() - conf2->theta() );

double phi1, phi2;
if (std::abs(dist1) < 1e-12)
{
phi1 = 0; // TODO previous phi?
//ROS_INFO("phi 1 is zero!");
}
else
{
//dist1 *= fast_sigmoid( 100.0 * (delta_s1.x()*cos(conf1->theta()) + delta_s1.y()*sin(conf1->theta())) ); // consider direction
//if (delta_s1.x()*cos(conf1->theta()) + delta_s1.y()*sin(conf1->theta()) < 0)
//dist1 = -dist1;

if (cfg_->trajectory.exact_arc_length)
phi1 = std::atan(cfg_->robot.wheelbase / dist1 * 2.0*std::sin(angle_diff1/2.0));
else
phi1 = std::atan(cfg_->robot.wheelbase / dist1 * angle_diff1);

// if we compute the sign of dist1 using the following method, the optimizer get's stuck (possibly due to non-smoothness and atan)
// In case if we apply the sign to the angle directly, it seems to work:
phi1 *= fast_sigmoid( 100.0 * (delta_s1.x()*cos(conf1->theta()) + delta_s1.y()*sin(conf1->theta())) ); // consider direction
}

if (std::abs(dist2) < 1e-12)
{
phi2 = phi1;
ROS_INFO("phi 2 is phi1!");
}
else
{
//dist2 *= fast_sigmoid( 100.0 * (delta_s2.x()*cos(conf2->theta()) + delta_s2.y()*sin(conf2->theta())) ); // consider direction
//if (delta_s2.x()*cos(conf2->theta()) + delta_s2.y()*sin(conf2->theta()) < 0)
// dist2 = -dist2;

if (cfg_->trajectory.exact_arc_length)
phi2 = std::atan(cfg_->robot.wheelbase / dist2 * 2.0*std::sin(angle_diff2/2.0));
else
phi2 = std::atan(cfg_->robot.wheelbase / dist2 * angle_diff2);

// if we compute the sign of dist1 using the following method, the optimizer get's stuck (possibly due to non-smoothness and atan).
// In case if we apply the sign to the angle directly, it seems to work:
phi2 *= fast_sigmoid( 100.0 * (delta_s2.x()*cos(conf2->theta()) + delta_s2.y()*sin(conf2->theta())) ); // consider direction
}

_error[0] = penaltyBoundToInterval(g2o::normalize_theta(phi2 - phi1)*2.0 / (dt1->dt() + dt2->dt()), cfg_->robot.max_steering_rate, 0.0);

ROS_ASSERT_MSG(std::isfinite(_error[0]), "EdgeSteeringRate::computeError() _error[0]\n",_error[0]);
}

public:

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

};

//! Corresponds to EdgeSteeringRate but with initial steering angle for the predecessor configuration
class EdgeSteeringRateStart : public BaseTebMultiEdge<1, double>
{
public:

/**
* @brief Construct edge.
*/
EdgeSteeringRateStart()
{
this->resize(3); // Since we derive from a g2o::BaseMultiEdge, set the desired number of vertices
}

/**
* @brief Actual cost function
*/
void computeError()
{
ROS_ASSERT_MSG(cfg_, "You must call setTebConfig on EdgeSteeringRateStart()");
const VertexPose* conf1 = static_cast<const VertexPose*>(_vertices[0]);
const VertexPose* conf2 = static_cast<const VertexPose*>(_vertices[1]);
const VertexTimeDiff* dt = static_cast<const VertexTimeDiff*>(_vertices[2]);

Eigen::Vector2d delta_s = conf2->estimate().position() - conf1->estimate().position();
double dist = delta_s.norm();
double angle_diff = g2o::normalize_theta( conf2->theta() - conf1->theta() );

double phi;
if (std::abs(dist) < 1e-12)
{
ROS_INFO("Start phi equals pervious phi!");
phi = _measurement;
}
else
{
//dist *= fast_sigmoid( 100.0 * (delta_s.x()*cos(conf1->theta()) + delta_s.y()*sin(conf1->theta())) ); // consider direction
//dist *= (double)g2o::sign( delta_s.x()*cos(conf1->theta()) + delta_s.y()*sin(conf1->theta()) ); // consider direction

if (cfg_->trajectory.exact_arc_length)
phi = std::atan(cfg_->robot.wheelbase / dist * 2.0*std::sin(angle_diff/2.0));
else
phi = std::atan(cfg_->robot.wheelbase / dist * angle_diff);

// if we compute the sign of dist1 using the following method, the optimizer get's stuck (possibly due to non-smoothness and atan).
// In case if we apply the sign to the angle directly, it seems to work:
phi *= fast_sigmoid( 100.0 * (delta_s.x()*cos(conf1->theta()) + delta_s.y()*sin(conf1->theta())) ); // consider direction
}

_error[0] = penaltyBoundToInterval(g2o::normalize_theta(phi - _measurement) / dt->dt(), cfg_->robot.max_steering_rate, 0.0);


ROS_ASSERT_MSG(std::isfinite(_error[0]), "EdgeSteeringRateStart::computeError() _error[0]\n",_error[0]);
}

void setInitialSteeringAngle(double steering_angle)
{
_measurement = steering_angle;
}

public:

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

};

//! Corresponds to EdgeSteeringRate but with initial steering angle for the successor configuration
class EdgeSteeringRateGoal : public BaseTebMultiEdge<1, double>
{
public:

/**
* @brief Construct edge.
*/
EdgeSteeringRateGoal()
{
this->resize(3); // Since we derive from a g2o::BaseMultiEdge, set the desired number of vertices
}

/**
* @brief Actual cost function
*/
void computeError()
{
ROS_ASSERT_MSG(cfg_, "You must call setTebConfig on EdgeSteeringRateGoal()");
const VertexPose* conf1 = static_cast<const VertexPose*>(_vertices[0]);
const VertexPose* conf2 = static_cast<const VertexPose*>(_vertices[1]);
const VertexTimeDiff* dt = static_cast<const VertexTimeDiff*>(_vertices[2]);

Eigen::Vector2d delta_s = conf2->estimate().position() - conf1->estimate().position();
double dist = delta_s.norm();
double angle_diff = g2o::normalize_theta( conf2->theta() - conf1->theta() );

double phi;
if (std::abs(dist) < 1e-12)
{
ROS_INFO("Goal phi is zero!");
phi = 0;
}
else
{
//dist *= fast_sigmoid( 100.0 * (delta_s.x()*cos(conf1->theta()) + delta_s.y()*sin(conf1->theta())) ); // consider direction

if (cfg_->trajectory.exact_arc_length)
phi = std::atan(cfg_->robot.wheelbase / dist * 2.0*std::sin(angle_diff/2.0));
else
phi = std::atan(cfg_->robot.wheelbase / dist * angle_diff);

// if we compute the sign of dist1 using the following method, the optimizer get's stuck (possibly due to non-smoothness and atan).
// In case if we apply the sign to the angle directly, it seems to work:
phi *= fast_sigmoid( 100.0 * (delta_s.x()*cos(conf1->theta()) + delta_s.y()*sin(conf1->theta())) ); // consider direction
}

_error[0] = penaltyBoundToInterval(g2o::normalize_theta(_measurement - phi) / dt->dt(), cfg_->robot.max_steering_rate, 0.0);


ROS_ASSERT_MSG(std::isfinite(_error[0]), "EdgeSteeringRateGoal::computeError() _error[0]\n",_error[0]);
}

void setGoalSteeringAngle(double steering_angle)
{
_measurement = steering_angle;
}

public:

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

};



} // end namespace

Expand Down
2 changes: 1 addition & 1 deletion include/teb_local_planner/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ inline bool smaller_than_abs(double i, double j) {return std::fabs(i)<std::fabs(
*/
inline double fast_sigmoid(double x)
{
return x / (1 + fabs(x));
return x / (1.0 + fabs(x));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions include/teb_local_planner/optimal_planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ class TebOptimalPlanner : public PlannerInterface
* @see buildGraph
* @see optimizeGraph
*/

void AddEdgesSteeringRate();

void AddEdgesPreferRotDir();

/**
Expand Down Expand Up @@ -694,6 +697,7 @@ class TebOptimalPlanner : public PlannerInterface
boost::shared_ptr<g2o::SparseOptimizer> optimizer_; //!< g2o optimizer for trajectory optimization
std::pair<bool, geometry_msgs::Twist> vel_start_; //!< Store the initial velocity at the start pose
std::pair<bool, geometry_msgs::Twist> vel_goal_; //!< Store the final velocity at the goal pose
double recent_steering_angle_ = 0.0; //!< Store last measured steering angle (for car-like setup)

bool initialized_; //!< Keeps track about the correct initialization of this class
bool optimized_; //!< This variable is \c true as long as the last optimization has been completed successful
Expand Down
4 changes: 4 additions & 0 deletions include/teb_local_planner/teb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class TebConfig
double acc_lim_y; //!< Maximum strafing acceleration of the robot
double acc_lim_theta; //!< Maximum angular acceleration of the robot
double min_turning_radius; //!< Minimum turning radius of a carlike robot (diff-drive robot: zero);
double max_steering_rate; //!< EXPERIMENTAL: Maximum steering rate of a carlike robot (THIS SIGNIFICANTLY AFFECTS PERFORMANCE AT THE MOMENT) [deactivate: zero]
double wheelbase; //!< The distance between the drive shaft and steering axle (only required for a carlike robot with 'cmd_angle_instead_rotvel' enabled); The value might be negative for back-wheeled robots!
bool cmd_angle_instead_rotvel; //!< Substitute the rotational velocity in the commanded velocity message by the corresponding steering angle (check 'axles_distance')
bool is_footprint_dynamic; //<! If true, updated the footprint before checking trajectory feasibility
Expand Down Expand Up @@ -159,6 +160,7 @@ class TebConfig
double weight_kinematics_nh; //!< Optimization weight for satisfying the non-holonomic kinematics
double weight_kinematics_forward_drive; //!< Optimization weight for forcing the robot to choose only forward directions (positive transl. velocities, only diffdrive robot)
double weight_kinematics_turning_radius; //!< Optimization weight for enforcing a minimum turning radius (carlike robots)
double weight_max_steering_rate; //!< EXPERIMENTAL: Optimization weight for enforcing a minimum steering rate of a carlike robot (TRY TO KEEP THE WEIGHT LOW OR DEACTIVATE, SINCE IT SIGNIFICANTLY AFFECTS PERFORMANCE AT THE MOMENT)
double weight_optimaltime; //!< Optimization weight for contracting the trajectory w.r.t. transition time
double weight_shortest_path; //!< Optimization weight for contracting the trajectory w.r.t. path length
double weight_obstacle; //!< Optimization weight for satisfying a minimum separation from obstacles
Expand Down Expand Up @@ -273,6 +275,7 @@ class TebConfig
robot.acc_lim_y = 0.5;
robot.acc_lim_theta = 0.5;
robot.min_turning_radius = 0;
robot.max_steering_rate = 0;
robot.wheelbase = 1.0;
robot.cmd_angle_instead_rotvel = false;
robot.is_footprint_dynamic = false;
Expand Down Expand Up @@ -322,6 +325,7 @@ class TebConfig
optim.weight_kinematics_nh = 1000;
optim.weight_kinematics_forward_drive = 1;
optim.weight_kinematics_turning_radius = 1;
optim.weight_max_steering_rate = 1;
optim.weight_optimaltime = 1;
optim.weight_shortest_path = 0;
optim.weight_obstacle = 50;
Expand Down
Loading