How to use the pymavlink.fgFDM.fgFDM function in pymavlink

To help you get started, we’ve selected a few pymavlink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArduPilot / ardupilot / Tools / autotest / jsb_sim / runsim.py View on Github external
# setup output to SITL sim
sim_out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sim_out.connect(interpret_address(opts.simout))
sim_out.setblocking(0)

# setup possible output to FlightGear for display
fg_out = None
if opts.fgout:
    fg_out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    fg_out.connect(interpret_address(opts.fgout))


# setup wind generator
wind = util.Wind(opts.wind)

fdm = fgFDM.fgFDM()

jsb_console.send('info\n')
jsb_console.send('resume\n')
jsb.expect(["trim computation time", "Trim Results"])
time.sleep(1.5)
jsb_console.send('step\n')
jsb_console.logfile = None

print("Simulator ready to fly")


def main_loop():
    """Run main loop."""
    tnow = time.time()
    last_report = tnow
    last_wind_update = tnow
github ArduPilot / pymavlink / tests / test_fgFDM.py View on Github external
def test_packparse(self):
        """Test the packing and parsing of an fgFDM packet"""
        fdm = fgFDM()     

        fdm.set('latitude', 67.4, units='degrees')
        fdm.set('longitude', 120.6, units='degrees')
        fdm.set('num_engines', 1)
        fdm.set('vcas', 44, units='mps')

        packedBytes = fdm.pack()
        
        parsedObj = fgFDM()
        parsedObj.parse(packedBytes)
        
        assert parsedObj.get('latitude', units='degrees') == 67.4
        assert round(parsedObj.get('vcas', units='knots'), 2) == 85.53
github ArduPilot / ardupilot / Tools / autotest / pysim / sim_wrapper.py View on Github external
fg_out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
fg_out.connect(fg_out_address)
fg_out.setblocking(0)

# setup input from SITL
sim_in = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sim_in.bind(sim_in_address)
sim_in.setblocking(1)

# setup output to SITL
sim_out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sim_out.connect(sim_out_address)
sim_out.setblocking(0)

# FG FDM object
fdm = fgFDM.fgFDM()

# create the model based on frame type
if opts.frame == 'heli':
    from helicopter import HeliCopter
    a = HeliCopter(frame=opts.frame)
    frame_rate = 400
elif opts.frame == 'IrisRos':
    from iris_ros import IrisRos
    a = IrisRos()
    frame_rate = 1000
elif opts.frame.startswith('CRRCSim'):
    from crrcsim import CRRCSim
    a = CRRCSim(frame=opts.frame)
    frame_rate = 360
elif opts.frame.startswith('rover'):
    from rover import Rover
github ArduPilot / ardupilot / Tools / autotest / ROS / runsim.py View on Github external
# setup output to SITL sim
sim_out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sim_out.connect(interpret_address(opts.simout))
sim_out.setblocking(0)

# setup possible output to FlightGear for display
fg_out = None
if opts.fgout:
    fg_out = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    fg_out.connect(interpret_address(opts.fgout))

# setup wind generator
wind = util.Wind(opts.wind)

fdm = fgFDM.fgFDM()
fdm_ctrls = fgFDM.fgFDM() # Setup another fdm object to send ctrls to ROS

time.sleep(1.5)

print("Simulator ready to fly")

def main_loop():
    '''run main loop'''
    tnow = time.time()
    last_report = tnow
    last_sim_input = tnow
    last_wind_update = tnow
    frame_count = 0
    paused = False
    timestamp = 0

    while True:
github MatrixPilot / MatrixPilot / Tools / MAVLink / mavlink / pymavlink / tools / mavplayback.py View on Github external
self.root = Tkinter.Tk()

        self.filesize = os.path.getsize(filename)
        self.filepos = 0.0

        self.mlog = mavutil.mavlink_connection(filename, planner_format=args.planner,
                                               robust_parsing=True)
        self.mout = []
        for m in args.out:
            self.mout.append(mavutil.mavlink_connection(m, input=False, baud=args.baudrate))

        self.fgout = []
        for f in args.fgout:
            self.fgout.append(mavutil.mavudp(f, input=False))

        self.fdm = fgFDM.fgFDM()

        self.msg = self.mlog.recv_match(condition=args.condition)
        if self.msg is None:
            sys.exit(1)
        self.last_timestamp = getattr(self.msg, '_timestamp')

        self.paused = False

        self.topframe = Tkinter.Frame(self.root)
        self.topframe.pack(side=Tkinter.TOP)

        self.frame = Tkinter.Frame(self.root)
        self.frame.pack(side=Tkinter.LEFT)

        self.slider = Tkinter.Scale(self.topframe, from_=0, to=1.0, resolution=0.01,
                                    orient=Tkinter.HORIZONTAL, command=self.slew)
github PX4 / HIL / runhil.py View on Github external
jsb_console = fdpexpect.fdspawn(jsb_out.fileno(), logfile=sys.stdout)
        jsb_console.delaybeforesend = 0
        jsb_console.logfile = None

        # setup input from jsbsim
        print("JSBSim FG FDM input on %s" % str(jsb_in_address))
        jsb_in = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        jsb_in.bind(jsb_in_address)
        jsb_in.setblocking(0)

        # set class data
        self.jsb = jsb
        self.jsb_in = jsb_in
        self.jsb_out = jsb_out
        self.jsb_console = jsb_console
        self.fdm = fgFDM.fgFDM()
github PX4 / HIL / run_sitl_fw.py View on Github external
jsb_console.delaybeforesend = 0
        jsb_console.logfile = None
        
        # setup input from jsbsim
        jsb_in_address = ('127.0.0.1', 5123)
        print("JSBSim FG FDM input on %s" % str(jsb_in_address))
        jsb_in = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        jsb_in.bind(jsb_in_address)
        jsb_in.setblocking(0)
        
        # set class data
        self.jsb = jsb
        self.jsb_in = jsb_in
        self.jsb_out = jsb_out
        self.jsb_console = jsb_console
        self.fdm = fgFDM.fgFDM()
github ArduPilot / pymavlink / tools / mavplayback.py View on Github external
self.root = tkinter.Tk()

        self.filesize = os.path.getsize(filename)
        self.filepos = 0.0

        self.mlog = mavutil.mavlink_connection(filename, planner_format=args.planner,
                                               robust_parsing=True)
        self.mout = []
        for m in args.out:
            self.mout.append(mavutil.mavlink_connection(m, input=False, baud=args.baudrate))

        self.fgout = []
        for f in args.fgout:
            self.fgout.append(mavutil.mavudp(f, input=False))

        self.fdm = fgFDM.fgFDM()

        self.msg = self.mlog.recv_match(condition=args.condition)
        if self.msg is None:
            sys.exit(1)
        self.last_timestamp = getattr(self.msg, '_timestamp')

        self.paused = False

        self.topframe = tkinter.Frame(self.root)
        self.topframe.pack(side=tkinter.TOP)

        self.frame = tkinter.Frame(self.root)
        self.frame.pack(side=tkinter.LEFT)

        self.slider = tkinter.Scale(self.topframe, from_=0, to=1.0, resolution=0.01,
                                    orient=tkinter.HORIZONTAL, command=self.slew)