Coverage for src/robotics_numpy/visualization/__init__.py: 25%

36 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-14 16:02 +0200

1""" 

2Visualization module for robotics-numpy 

3 

4This module provides 3D visualization functionality including: 

5- Robot model visualization using Plotly 

6- Transformation frame visualization 

7- Trajectory plotting 

8- Joint space and Cartesian space plots 

9 

10This is an optional module that requires Plotly. Install with: 

11pip install robotics-numpy[visualization] 

12""" 

13 

14# Check if plotly is available 

15try: 

16 import plotly.graph_objects # Test actual plotly functionality 

17 _HAS_PLOTLY = True 

18except ImportError: 

19 _HAS_PLOTLY = False 

20 

21if _HAS_PLOTLY: 

22 # Visualization functions will be implemented in Phase 2 

23 # from .plot_3d import ( 

24 # plot_frame, 

25 # plot_frames, 

26 # plot_trajectory, 

27 # plot_robot, 

28 # ) 

29 

30 # from .plot_joints import ( 

31 # plot_joint_trajectory, 

32 # plot_joint_positions, 

33 # plot_joint_velocities, 

34 # ) 

35 

36 # from .plot_utils import ( 

37 # create_figure, 

38 # add_coordinate_frame, 

39 # add_robot_links, 

40 # animate_trajectory, 

41 # ) 

42 

43 __all__ = [ 

44 # Will be populated in Phase 2 

45 # "plot_frame", 

46 # "plot_frames", 

47 # "plot_trajectory", 

48 # "plot_robot", 

49 # "plot_joint_trajectory", 

50 # "plot_joint_positions", 

51 # "plot_joint_velocities", 

52 # "create_figure", 

53 # "add_coordinate_frame", 

54 # "add_robot_links", 

55 # "animate_trajectory", 

56 ] 

57else: 

58 __all__ = [] 

59 

60# Version placeholder for Phase 2 

61_VISUALIZATION_VERSION = "0.2.0-dev" 

62 

63def check_plotly() -> bool: 

64 """Check if Plotly is available for visualization.""" 

65 return _HAS_PLOTLY 

66 

67def about_visualization() -> None: 

68 """Print information about visualization capabilities.""" 

69 print("Robotics NumPy - Visualization Module") 

70 print("====================================") 

71 print() 

72 if _HAS_PLOTLY: 

73 print("✅ Plotly is available") 

74 print(" Visualization features will be available in Phase 2") 

75 else: 

76 print("❌ Plotly is not installed") 

77 print(" Install with: pip install robotics-numpy[visualization]") 

78 print() 

79 print("Planned visualization features (Phase 2):") 

80 print(" - 3D coordinate frames and transformations") 

81 print(" - Robot model visualization") 

82 print(" - Trajectory plotting (joint and Cartesian space)") 

83 print(" - Animation of robot motion") 

84 print(" - Interactive plots with Plotly") 

85 print(" - Export to HTML and static images") 

86 

87# Provide helpful error messages when visualization is not available 

88if not _HAS_PLOTLY: 

89 def _plotly_not_available(*args, **kwargs): 

90 raise ImportError( 

91 "Plotly is required for visualization features. " 

92 "Install with: pip install robotics-numpy[visualization]" 

93 ) 

94 

95 # Create placeholder functions that give helpful error messages 

96 plot_frame = _plotly_not_available 

97 plot_frames = _plotly_not_available 

98 plot_trajectory = _plotly_not_available 

99 plot_robot = _plotly_not_available 

100 

101 __all__.extend([ 

102 "plot_frame", 

103 "plot_frames", 

104 "plot_trajectory", 

105 "plot_robot", 

106 ])