Go to the documentation of this file.
40 #include <mbf_msgs/ExePathResult.h>
41 #include <mbf_msgs/GetPathResult.h>
45 #include <std_msgs/Float32.h>
54 #define DEBUG_CALL(method) method
56 #define DEBUG_CALL(method)
70 const geometry_msgs::TwistStamped& velocity,
71 geometry_msgs::TwistStamped& cmd_vel, std::string& message)
77 std::array<float, 3> bary_coords;
78 std::array<mesh_map::Vector, 3> vertices;
83 if (
auto search_res_opt =
map_ptr->searchContainingFace(
86 auto search_res = *search_res_opt;
88 vertices = std::get<1>(search_res);
89 bary_coords = std::get<2>(search_res);
97 return mbf_msgs::ExePathResult::OUT_OF_MAP;
103 vertices =
mesh.getVertexPositionsOfFace(face);
107 float dist_to_surface;
111 robot_pos, vertices, bary_coords, dist_to_surface)
112 && dist_to_surface <
config.max_search_distance)
117 else if (
auto search_res_opt =
map_ptr->searchNeighbourFaces(
122 auto search_res = *search_res_opt;
124 vertices = std::get<1>(search_res);
125 bary_coords = std::get<2>(search_res);
130 else if(
auto search_res_opt =
map_ptr->searchContainingFace(
134 auto search_res = *search_res_opt;
136 vertices = std::get<1>(search_res);
137 bary_coords = std::get<2>(search_res);
143 return mbf_msgs::ExePathResult::OUT_OF_MAP;
148 std::array<lvr2::VertexHandle, 3> handles =
map_ptr->mesh_ptr->getVerticesOfFace(face);
152 const auto& opt_dir =
map_ptr->directionAtPosition(
vector_map, handles, bary_coords);
157 return mbf_msgs::ExePathResult::FAILURE;
160 float cost =
map_ptr->costAtPosition(handles, bary_coords);
163 cmd_vel.twist.linear.x = std::min(
config.max_lin_velocity, velocities[0] *
config.lin_vel_factor);
164 cmd_vel.twist.angular.z = std::min(
config.max_ang_velocity, velocities[1] *
config.ang_vel_factor);
169 return mbf_msgs::ExePathResult::CANCELED;
171 return mbf_msgs::ExePathResult::SUCCESS;
178 return goal_distance <= static_cast<float>(dist_tolerance) && angle <= static_cast<float>(angle_tolerance);
208 tf2::Vector3 v =
transform.getBasis() * axis;
214 return mesh_map::Vector(pose.pose.position.x, pose.pose.position.y, pose.pose.position.z);
219 return exp(-value * value / 2 * sigma_squared) / sqrt(2 *
M_PI * sigma_squared);
227 const float& mesh_cost)
234 float angular_velocity = copysignf(phi *
config.max_ang_velocity /
M_PI, -sign_phi);
235 const float max_angle =
config.max_angle *
M_PI / 180.0;
236 const float max_linear =
config.max_lin_velocity;
237 float linear_velocity = phi <= max_angle ? max_linear - (phi * max_linear / max_angle) : 0.0;
238 return { linear_velocity, angular_velocity };
252 new dynamic_reconfigure::Server<mesh_controller::MeshControllerConfig>(private_nh));
mesh_map::Normal robot_dir
MeshControllerConfig config
current mesh controller configuration
mesh_map::Normal goal_dir
the goal's and robot's orientation
void reconfigureCallback(mesh_controller::MeshControllerConfig &cfg, uint32_t level)
reconfigure callback function which is called if a dynamic reconfiguration were triggered.
#define DEBUG_CALL(method)
lvr2::DenseVertexMap< mesh_map::Vector > vector_map
The vector field to the goal.
#define ROS_ERROR_STREAM(args)
boost::shared_ptr< dynamic_reconfigure::Server< mesh_controller::MeshControllerConfig > > reconfigure_server_ptr
shared pointer to dynamic reconfigure server
void fromMsg(const A &, B &b)
virtual bool initialize(const std::string &plugin_name, const boost::shared_ptr< tf2_ros::Buffer > &tf_ptr, const boost::shared_ptr< mesh_map::MeshMap > &mesh_map_ptr)
Initializes the controller plugin with a name, a tf pointer and a mesh map pointer.
vector< geometry_msgs::PoseStamped > current_plan
the current set plan
std_msgs::ColorRGBA color(const float &r, const float &g, const float &b, const float &a=1.0)
MeshController()
Constructor.
BaseVector< CoordT > cross(const BaseVector &other) const
void publish(const boost::shared_ptr< M > &message) const
FaceHandle unwrap() const
Publisher advertise(AdvertiseOptions &ops)
std::array< float, 2 > naiveControl(const mesh_map::Vector &robot_pos, const mesh_map::Normal &robot_dir, const mesh_map::Vector &mesh_dir, const mesh_map::Normal &mesh_normal, const float &mesh_cost)
lvr2::BaseVector< float > Vector
dynamic_reconfigure::Server< mesh_controller::MeshControllerConfig >::CallbackType config_callback
dynamic reconfigure callback function binding
boost::shared_ptr< mesh_map::MeshMap > map_ptr
shared pointer to the used mesh map
virtual bool isGoalReached(double dist_tolerance, double angle_tolerance)
Checks if the robot reached to goal pose.
float gaussValue(const float &sigma_squared, const float &value)
virtual ~MeshController()
Destructor.
double angle(const geometry_msgs::PoseStamped &pose1, const geometry_msgs::PoseStamped &pose2)
mesh_map::Vector poseToPositionVector(const geometry_msgs::PoseStamped &pose)
mesh_map::Normal poseToDirectionVector(const geometry_msgs::PoseStamped &pose, const tf2::Vector3 &axis=tf2::Vector3(1, 0, 0))
mesh_map::Vector goal_pos
the goal and robot pose
#define ROS_INFO_STREAM(args)
std::atomic_bool cancel_requested
flag to handle cancel requests
virtual bool setPlan(const std::vector< geometry_msgs::PoseStamped > &plan)
Sets the current plan to follow, it also sets the vector field.
lvr2::OptionalFaceHandle current_face
The triangle on which the robot is located.
T linearCombineBarycentricCoords(const std::array< lvr2::VertexHandle, 3 > &vertices, const lvr2::VertexMap< T > &attribute_map, const std::array< float, 3 > &barycentric_coords)
PLUGINLIB_EXPORT_CLASS(mesh_controller::MeshController, mbf_mesh_core::MeshController)
mesh_map::Vector robot_pos
ros::Publisher angle_pub
publishes the angle between the robots orientation and the goal vector field for debug purposes
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
virtual bool cancel()
Requests the planner to cancel, e.g. if it takes too much time.
CoordT dot(const BaseVector &other) const
lvr2::Normal< float > Normal
bool projectedBarycentricCoords(const Vector &p, const std::array< Vector, 3 > &vertices, std::array< float, 3 > &barycentric_coords)
virtual uint32_t computeVelocityCommands(const geometry_msgs::PoseStamped &pose, const geometry_msgs::TwistStamped &velocity, geometry_msgs::TwistStamped &cmd_vel, std::string &message)
Given the current position, orientation, and velocity of the robot, compute the next velocity command...
mesh_controller
Author(s): Sebastian Pütz
, Sabrina Frohn
autogenerated on Thu Jan 25 2024 03:43:00