Git Product home page Git Product logo

earth_centric_3d_visualizer's Introduction

RenderRPO Class Documentation

Overview

The RenderRPO class is designed to render a Relative Positioning Operation (RPO) scenario in space with the Earth, a chaser satellite, and a target satellite using the pyvista and pyvistaqt libraries.

Dependencies

To use the RenderRPO class, the following libraries must be installed:

import pyvista
from pyvista import examples
import numpy as np
from pyvistaqt import BackgroundPlotter
import os
import datetime
import math

Class Definition

class RenderRPO:

    def __init__(self):
        self.timer_count = 0

        self.chaser_stl_path, self.target_stl_path = 'models/DART_STL.stl', 'models/DART_STL.stl'
        self.pl, self.earth, self.chaser_mesh, self.target_mesh = self._BuildScene()
        self.light = self._set_light_position_by_date(datetime.datetime.now())
        self.pl.add_light(self.light)

        self.earthaxis = pyvista.AxesActor()
        self.earthaxis.origin = self.earth.center
        scale = 1000
        self.earthaxis.SetTotalLength(6371+scale, 6371+scale, 6371+scale)
        self.earthaxis.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor((1, 0, 0))
        self.earthaxis.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetColor((0, 1, 0))
        self.earthaxis.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetColor((0, 0, 1))
        
        self.pl.add_axes()

        print('Building scene...')
        print('The units of the scene are in km.')
        print('Scene built.')
        print('Rendering scene...')

    def _BuildScene(self):
        earth, earth_texture = self._BuildEci()

        print('Building satellites...')
        print(f'Chaser: {self.chaser_stl_path}')
        print(f'Target: {self.target_stl_path}')
        chaser_mesh, target_mesh = self._BuildSatellites(self.chaser_stl_path, self.target_stl_path)

        pl = BackgroundPlotter(lighting="none")
        cubemap = examples.download_cubemap_space_16k()
        _ = pl.add_actor(cubemap.to_skybox())
        pl.set_environment_texture(cubemap, True)

        pl.add_mesh(earth, texture=earth_texture, smooth_shading=True)
        pl.add_mesh(chaser_mesh, color='red')
        pl.add_mesh(target_mesh, color='blue')

        print('Returning plotter and objects.')
        return [pl, earth, chaser_mesh, target_mesh]

    # ... (Other methods continue in a similar fashion)

Methods

  • __init__(self): Initializes the rendering plotter, loads the meshes, and sets up the scene.
  • _BuildScene(self): Constructs the visual scene with the Earth, chaser, and target meshes.
  • _BuildEci(self): Creates the Earth mesh with texture.
  • _BuildSatellites(self, chaser_stl_path, target_stl_path): Loads the STL models for the chaser and target satellites.
  • set_chaser_position(self, position_eci): Sets the chaser's position in Earth-Centered Inertial (ECI) coordinates.
  • focus_on_chaser(self): Adjusts the camera to focus on the chaser satellite.
  • animate(self, update_freq=30): Initiates the animation of the satellites.
  • update_scene(self, event): Updates the scene; meant to be called by a Qt timer.
  • _distanceFromEarthSurface(self, position_eci): Calculates the distance of an object from Earth's surface.
  • _set_light_position_by_date(self, date_time): Sets the lighting based on the current date and time to simulate sunlight.

Usage

To use the RenderRPO class, instantiate it and call the appropriate methods for your simulation needs. Ensure that the models/DART_STL.stl paths are correctly set to the locations of your STL files.

Notes

  • The class is designed to work with the pyvistaqt BackgroundPlotter for interactive visualization.
  • Error handling for file paths and STL file integrity should be considered when implementing in a production environment.
  • The _set_light_position_by_date function is a simplification and may need more accurate astronomical calculations for precise simulations.

Authors

  • [Vincent Chen]

earth_centric_3d_visualizer's People

Contributors

vince-c156 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.