'''
This repo contains two ROS 2 packages:
bim_viz- visualizes a BIM building (static) and a robot (moving) in RViz using mesh markers.autoemailserver- a service node that sends alert emails when an event occurs at a given XYZ location.
Tested on ROS 2 Humble (Ubuntu 22.04).
# From your ROS 2 workspace root
colcon build --symlink-install
source install/setup.bash
If you add/modify Python scripts, re-run colcon build and re-source.
- Publishes two independent markers:
/building_marker: a static building mesh (flat grey), latched (TRANSIENT_LOCAL)./robot_marker: a moving robot mesh (red by default), follows/odomposition.
- Both are published in the
mapframe. - RViz config subscribes to both topics.
ros2 launch bim_viz show_bim_and_robot.launch.py
RViz should open with a grid + both meshes visible.
-
Published topics
/building_marker-visualization_msgs/Marker(latched)/robot_marker-visualization_msgs/Marker(periodic updates)
-
Consumed topics
/odom-nav_msgs/Odometry(robot position; robot starts at 0,0,0 until messages arrive)
-
Key node parameters (override via launch or CLI)
frame_id(string) - defaultmapbuilding_mesh_resource(string) - defaultpackage://bim_viz/meshes/building.stlbuilding_scale(double) - default1.0building_offset_xyz(double[3]) - default[0,0,0]building_color_rgba(double[4]) - default[0.6,0.6,0.6,1.0](flat grey)building_use_embedded_materials(bool) - defaultfalserobot_mesh_resource(string) - defaultpackage://bim_viz/meshes/building.stlrobot_scale(double) - default0.01robot_color_rgba(double[4]) - default[1.0,0.1,0.1,1.0](red)robot_use_embedded_materials(bool) - defaultfalseodom_topic(string) - default/odompublish_rate_hz(double) - default20.0
STL cannot carry textures. If you want textured robots, use a .dae mesh with UV + textures and set
robot_use_embedded_materials=true.
- If the viewport freezes or RViz crashes, run with software GL:
LIBGL_ALWAYS_SOFTWARE=1 ros2 launch bim_viz show_bim_and_robot.launch.py - If you see shimmer/'reflective' look:
- In RViz ? the Marker display ? disable Lighting.
- Keep scene scale reasonable; very large meshes can cause near/far plane artifacts.
Exposes a service /notify_event. You send a location (geometry_msgs/Point) and an event type (int32), and it sends an email to a hardcoded recipient based on the event type.
- Example mapping (editable in code):
0? fire ?fire.officer@example.com(subject[ALERT][FIRE] ...)
ros2 launch autoemailserver auto_email_server.launch.py
ros2 service call /notify_event autoemailserver/srv/NotifyEvent "{location: {x: 10.0, y: 20.0, z: 0.0}, event_type: 0}"
You should see a log �Email sent to �� if SMTP is configured correctly.
Edit autoemailserver/config/smtp.yaml (or override via CLI params):
auto_email_server:
ros__parameters:
smtp.server: "smtp.gmail.com"
smtp.port: 587
smtp.use_ssl: false
smtp.username: "yourname@gmail.com"
smtp.password: "" # recommended: leave blank and export env var SMTP_PASSWORD
smtp.from: "yourname@gmail.com"
smtp.timeout: 20.0
Recommended: keep passwords out of files.
export SMTP_PASSWORD="your_app_password_here"
Open autoemailserver/scripts/auto_email_server.py:
- Routing table (recipient per event type):
self.routing = { 0: {'email': 'fire.officer@example.com', 'subject_prefix': '[ALERT][FIRE]'}, # add more types here... } - Email body:
_format_body(event_type, location)- returns the message text.- Add new branches for new event types.
https://www.youtube.com/watch?v=y5IasMFYdBc
https://www.cianwang.com/news/web-knowledge/smtp
For Gmail, use App Passwords (requires 2FA). Standard username/password often won�t work without an app password.
RViz opens but shows nothing
- Check Fixed Frame in RViz is
map. - Add two displays:
- Marker
/building_marker - Marker
/robot_marker
- Marker
*executable .py not found
- Ensure the script has shebang and is executable:
chmod +x <package>/scripts/*.py - Make sure
CMakeLists.txthas:install(PROGRAMS scripts/xxx.py DESTINATION lib/${PROJECT_NAME}) - Rebuild +
source install/setup.bash.
No email sent
- Check server logs (auth errors, connection errors).
- Verify SMTP params and credentials.
- Some SMTP providers block port 25; use 587 (STARTTLS) or 465 (SSL) as configured.
Robot doesn�t move
- Verify
/odomis publishing:ros2 topic echo /odom - If odom is on a different topic, set
odom_topicparameter accordingly (in the launch or via--ros-args -p odom_topic:=...).
ros2 launch bim_viz show_bim_and_robot.launch.py
ros2 launch autoemailserver auto_email_server.launch.py
ros2 service call /notify_event autoemailserver/srv/NotifyEvent "{location: {x: 10.0, y: 20.0, z: 0.0}, event_type: 0}"
- Change scales/offsets/colors for building/robot via launch params or by editing defaults in the marker node.
- Add more event types by extending
self.routingand_format_body. - Textures require .dae meshes with UV/materials; set
*_use_embedded_materials=trueand ensure textures are installed under the package and referenced withpackage://. '''