Skip to content

Commit 023c3d9

Browse files
authored
Behavior Tree RViz Panel Performance Fix (#291)
* Save rviz * Performance imrpvoements * Enable save zoom setting * Enable save zoom setting
1 parent 72bb429 commit 023c3d9

5 files changed

Lines changed: 394 additions & 59 deletions

File tree

CLAUDE.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
AirStack is a comprehensive autonomous aerial robotics stack developed by AirLab CMU. It provides a complete end-to-end system for autonomous drone operations including simulation, robot control, and ground control station.
8+
9+
## Key Components
10+
11+
The repository is organized into four main components:
12+
13+
- **robot/**: Onboard autonomy stack for drones (ROS 2 based)
14+
- **simulation/**: Isaac Sim integration and simulation environments
15+
- **gcs/**: Ground Control Station for mission planning and monitoring
16+
- **common/**: Shared ROS packages and utilities used across components
17+
18+
## Development Commands
19+
20+
### AirStack CLI Tool
21+
The project uses a custom CLI tool `./airstack.sh` for common operations:
22+
23+
```bash
24+
# Setup and installation
25+
./airstack setup # Configure AirStack and add to PATH
26+
./airstack install # Install Docker and dependencies
27+
28+
# Container management
29+
./airstack up [service] # Start services with Docker Compose
30+
./airstack stop [service] # Stop services
31+
./airstack status # Show container status
32+
./airstack connect [name] # Connect to running container (supports partial names)
33+
./airstack logs [name] # View container logs
34+
35+
# Development tasks
36+
./airstack build # Build the workspace
37+
./airstack test # Run tests
38+
./airstack docs # Build documentation
39+
```
40+
41+
### ROS 2 Build Commands
42+
Inside robot containers, use these aliases:
43+
- `bws`: Build the ROS workspace (`colcon build`)
44+
- `sws`: Source the workspace (`source install/setup.bash`)
45+
46+
### VSCode Integration
47+
The repository includes VSCode tasks:
48+
- **Build ros_ws Debug**: Builds ROS workspace in debug mode using `bws --cmake-args '-DCMAKE_BUILD_TYPE=Debug'`
49+
50+
## Architecture
51+
52+
### Robot Autonomy Stack (robot/ros_ws/src/autonomy/)
53+
54+
The autonomy stack follows a layered architecture with numbered modules:
55+
56+
- **0_interface/**: Robot hardware interface and safety monitors
57+
- `mavros_interface`: Communication with flight controller
58+
- `drone_safety_monitor`: Safety monitoring and emergency handling
59+
- `robot_interface`: High-level robot abstraction
60+
61+
- **1_sensors/**: Sensor integration and processing
62+
- `camera_param_server`: Camera calibration management
63+
- `gimbal_stabilizer`: Gimbal control and stabilization
64+
- `sensor_interfaces`: Common sensor message definitions
65+
66+
- **2_perception/**: State estimation and environment perception
67+
- `macvo_ros2`: Visual-inertial odometry system
68+
69+
- **3_local/**: Local planning and control
70+
- `a_world_models/`: Local world representation
71+
- `disparity_expansion`: Obstacle detection from stereo
72+
- `disparity_graph`: Graph-based obstacle representation
73+
- `cost_map_interface`: Cost map utilities
74+
- `b_planners/`: Local motion planning
75+
- `droan_local_planner`: DROAN obstacle avoidance planner
76+
- `takeoff_landing_planner`: Specialized takeoff/landing
77+
- `trajectory_library`: Trajectory generation utilities
78+
- `c_controls/`: Low-level control
79+
- `trajectory_controller`: Trajectory tracking controller
80+
- `attitude_controller`: Attitude control
81+
- `pid_controller`: PID control utilities
82+
83+
- **4_global/**: Global planning and mapping
84+
- `a_world_models/`: Global world representation
85+
- `vdb_mapping_ros2`: VDB-based 3D mapping
86+
- `b_planners/`: Global path planning
87+
- `random_walk`: Random exploration planner
88+
- `ensemble_planner`: Multi-planner coordination
89+
90+
- **5_behavior/**: High-level mission execution
91+
- `behavior_tree`: Behavior tree framework
92+
- `behavior_executive`: Mission execution engine
93+
- `rqt_behavior_tree_command`: GUI for behavior tree control
94+
95+
### Docker Architecture
96+
97+
Each component has its own Docker setup:
98+
- `robot/docker/`: Robot container with ROS 2 and autonomy stack
99+
- `simulation/isaac-sim/docker/`: Isaac Sim simulation environment
100+
- `gcs/docker/`: Ground control station container
101+
- `docs/docker/`: Documentation building container
102+
103+
The main `docker-compose.yaml` includes all component compose files for unified management.
104+
105+
## Common Patterns
106+
107+
### ROS 2 Launch Files
108+
- Bringup packages (`*_bringup/`) contain launch files for each subsystem
109+
- Launch files are organized by functionality and can be composed
110+
- Example: `ros2 launch robot_bringup robot.launch.py`
111+
112+
### Configuration Management
113+
- Parameters stored in `config/` directories within packages
114+
- YAML files for node parameters and launch configurations
115+
- Environment variables configured in `.env` file
116+
117+
### Testing
118+
- Test files located in `test/` directories within packages
119+
- Integration tests in `tests/` at repository root
120+
121+
## Important Notes
122+
123+
- The project uses ROS 2 Humble
124+
- Primary development is done in Docker containers
125+
- Documentation is built with MkDocs and hosted at docs.theairlab.org
126+
- The autonomy stack supports both simulation (SITL) and hardware deployment
127+
- Container networking uses custom bridge network (172.31.0.0/24)

common/ros_packages/rviz_behavior_tree_panel/include/rviz_behavior_tree_panel/behavior_tree_panel.hpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,25 @@
4848
#include <xdot_cpp/ui/dot_widget.h>
4949
#include <behavior_tree_msgs/msg/graph_viz_xdot.hpp>
5050
#include <behavior_tree_msgs/msg/graph_viz_xdot_compressed.hpp>
51+
#include <unordered_set>
52+
#include <unordered_map>
5153

5254
namespace rviz_behavior_tree_panel
5355
{
5456

57+
struct GraphDiff {
58+
std::unordered_set<std::string> added_nodes;
59+
std::unordered_set<std::string> removed_nodes;
60+
std::unordered_set<std::string> modified_nodes;
61+
std::unordered_set<std::string> added_edges;
62+
std::unordered_set<std::string> removed_edges;
63+
64+
bool hasChanges() const {
65+
return !added_nodes.empty() || !removed_nodes.empty() || !modified_nodes.empty() ||
66+
!added_edges.empty() || !removed_edges.empty();
67+
}
68+
};
69+
5570
class BehaviorTreePanel : public rviz_common::Panel
5671
{
5772
Q_OBJECT
@@ -72,10 +87,15 @@ class BehaviorTreePanel : public rviz_common::Panel
7287
void updateAvailableTopics();
7388
void subscribeToTopic(const std::string& topic_name);
7489

90+
GraphDiff computeGraphDiff(const std::string& old_graph, const std::string& new_graph);
91+
std::unordered_set<std::string> extractNodes(const std::string& graph_data);
92+
std::unordered_set<std::string> extractEdges(const std::string& graph_data);
93+
7594
private slots:
7695
void onTopicChanged();
7796
void onTopicTextChanged(const QString & text);
7897
void onRefreshTopics();
98+
void onThrottledUpdate();
7999

80100
private:
81101
QVBoxLayout * layout_;
@@ -86,9 +106,15 @@ private slots:
86106
QLabel * status_label_;
87107
xdot_cpp::ui::DotWidget * dot_widget_;
88108
QTimer * topic_refresh_timer_;
89-
109+
QTimer * update_throttle_timer_;
110+
90111
std::string previous_graphviz_;
112+
std::string pending_graphviz_;
91113
std::string current_topic_;
114+
bool has_pending_update_;
115+
double saved_zoom_factor_;
116+
117+
static constexpr int UPDATE_INTERVAL_MS = 100;
92118
};
93119

94120
} // namespace rviz_behavior_tree_panel

0 commit comments

Comments
 (0)