Go to the documentation of this file.
6 #include <tf2/LinearMath/Transform.h>
7 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
8 #include <geometry_msgs/Pose.h>
9 #include <geometry_msgs/Quaternion.h>
10 #include <geometry_msgs/Vector3.h>
11 #include <visualization_msgs/Marker.h>
52 ROS_WARN(
"Odom was not yet set. It is set now.");
63 odom.
a = fmod(new_odom.
a -
prev_odom_.
a + 3*M_PI, 2*M_PI) - M_PI;
96 #pragma GCC diagnostic push
97 #pragma GCC diagnostic ignored "-Wunused-result"
98 system(
"aplay --device front:CARD=Device_1,DEV=0 ~/.emc/system/src/emc_system/sounds/doorbell.wav &");
99 #pragma GCC diagnostic pop
126 visualization_msgs::Marker pathMarker;
127 pathMarker.header.frame_id =
"map";
128 pathMarker.header.stamp = ros::Time();
129 pathMarker.ns =
"path";
131 pathMarker.type = visualization_msgs::Marker::LINE_STRIP;
132 pathMarker.action = visualization_msgs::Marker::ADD;
133 pathMarker.color.a = 1.0;
134 pathMarker.color.r = color[0];
135 pathMarker.color.g = color[1];
136 pathMarker.color.b = color[2];
137 pathMarker.pose.orientation.w = 1.0;
138 pathMarker.scale.x = width;
141 geometry_msgs::Point point;
142 if ((*it).size() < 2)
144 ROS_WARN_STREAM(
"Point at index " <<
std::distance(path.begin(), it) <<
" has too few dimensions (expected at least 2, got " << (*it).size() <<
"), skipping.");
149 if ((*it).size() == 2)
156 if ((*it).size() > 3)
158 ROS_WARN_STREAM(
"point at index " <<
std::distance(path.begin(), it) <<
" has unused dimensions (expected 2 or 3, got " << (*it).size() <<
").");
161 pathMarker.points.push_back(point);
163 if (pathMarker.points.size() < 2)
165 ROS_ERROR_STREAM(
"Not enough valid points (expected at least 2, got " << pathMarker.points.size() <<
").");
176 pose.setOrigin(tf2::Vector3(px, py, pz));
177 pose.setRotation(tf2::Quaternion(rx, ry, rz, rw));
187 q.setRPY(roll, pitch, yaw);
bool readLaserData(LaserData &scan)
Receive new laser data if available.
void localization_viz_send_laser_scan(double angle_min, double angle_max, double angle_inc, int subsample, std::vector< float > prediction)
IO(Communication *comm=nullptr)
bool readOdometryData(OdometryData &odom)
Receive new odometrydata if available.
void sendPoseEstimate(const geometry_msgs::Transform &pose)
bool sendPath(std::vector< std::vector< double >> path, std::array< double, 3 > color={0.0, 0.0, 0.0}, double width=0.02, int id=0)
Send a path to be drawn in rviz.
bool readPoseData(PoseData &pose)
bool resetOdometry()
Set the current position as (0,0,0)
bool readOdometryData(OdometryData &odom)
void localization_viz_send_laser_scan(double angle_min, double angle_max, double angle_inc, int subsample, std::vector< float > prediction)
void localization_viz_send_particles(int N, std::vector< std::vector< double >> particle_poses, double mapOrientation)
void sendBaseReference(double vx, double vy, double va)
Send a command velocity to the robot.
void sendBaseVelocity(double vx, double vy, double va)
bool readFrontBumperData(BumperData &bumper)
Receive new BumperData from the front bumper.
void speak(const std::string &text)
void localization_viz_send_pose(std::vector< double > pose, double mapOrientation)
void sendMarker(visualization_msgs::Marker marker)
void sendOpendoorRequest()
void localization_viz_send_particles(int N, std::vector< std::vector< double >> particle_poses, double mapOrientation)
bool ok()
Check connection to the robot.
void play(const std::string &file)
Play a sound file out loud. The file must be placed in the ~/MRC_audio folder and must be of ....
void localization_viz_send_pose(std::vector< double > pose, double mapOrientation)
bool readFrontBumperData(BumperData &bumper)
void sendOpendoorRequest()
Broadcast a request to open nearby doors. Works in simulator only.
bool readPoseData(PoseData &pose)
Receive new pose data if available.
void play(const std::string &file)
bool readBackBumperData(BumperData &bumper)
bool sendPoseEstimate(double x, double y, double yaw)
Send an estimate of the current robot pose to be shown in rviz, relative to the centre of the map (sa...
bool readLaserData(LaserData &scan)
bool readBackBumperData(BumperData &bumper)
Receive new BumperData from the rear bumper.
void speak(const std::string &text)
Make the robot speak the input text. This function is non-blocking.