Auterion / px4-jsbsim-bridge

JSBSim bridge for PX4 SITL/HITL simulations
BSD 3-Clause "New" or "Revised" License
26 stars 38 forks source link

Enable Hardware-In-The-Loop simulation for JSBSim #28

Open Jaeyoung-Lim opened 3 years ago

Jaeyoung-Lim commented 3 years ago

Describe problem solved by this pull request Currently the px4-jsbsim-bridge can only be used to run Software-In-The-Loop(SITL) simulations. While this is useful for evaluating the software changes in firmware, it may not reveal issues that may appear only deployed on hardware. PX4 also supports Hardware-In-The-Loop(HITL) simulation. However, this was not exposed to the jsbsim-bridge

Describe your solution This commit adds configuration options for running HITL simulation with the PX4 JSBSim bridge.

The device path / baudrate can be passed with the command line when running the binary directly with flag -d and -b. e.g.

HEADLESS=1 ./jsbsim_bridge rascal -d /dev/ttyACM0 -s ~/src/Firmware/Tools/jsbsim_bridge/scene/LSZH.xml

or to set the baudrate

HEADLESS=1 ./jsbsim_bridge rascal -d /dev/ttyACM0 -b 921600 -s ~/src/Firmware/Tools/jsbsim_bridge/scene/LSZH.xml

The bridge is configured to be run with a HITL when the device path -d is provided. The baudrate is configured to be 921600 by default, but can be also configured through a -b flag.

Test data / coverage [WIP]()

Additional context

fahadmaqbool16 commented 2 years ago

@Jaeyoung-Lim . Hi I am interested in running HITL with JSBSim bridge, Can you please guide me with the steps to follow for this. any help will be highly appreciated.

Jaeyoung-Lim commented 2 years ago

@fahadmaqbool16 The pull request already explains how to test this PR, what additional information do you need?

fahadmaqbool16 commented 2 years ago

@Jaeyoung-Lim thanks for your reply, when I run

HEADLESS=1 ./jsbsim_bridge rascal -d /dev/ttyACM0 -s ~/src/Firmware/Tools/jsbsim_bridge/scene/LSZH.xml

 in Tools directory I get 

bash: ./Tools/jsbsim_bridge/: Is a directory

Nothing happens.

Jaeyoung-Lim commented 2 years ago

@fahadmaqbool16 If you read the PR description, your command does not match what I have described

Also your log says that what you tried to execute is a directory, therefore it is expected that nothing happens

fahadmaqbool16 commented 2 years ago

No, actually I was changing the directory to Tools to see if the command works, but it didn't. To clarify, I am

running this command HEADLESS=1 ./jsbsim_bridge rascal -d /dev/ttyACM0 -s ~/src/Firmware/Tools/jsbsim_bridge/scene/LSZH.xml

in the Tools directory, I get the error

ofp@ubuntu:~/PX4-Autopilot/Tools$ HEADLESS=1 ./jsbsim_bridge rascal -d /dev/ttyACM0 -s ~/src/Firmware/Tools/jsbsim_bridge/scene/LSZH.xml

bash: ./jsbsim_bridge: Is a directory

if this command is not correct, can you please tell the correct command,

fahadmaqbool16 commented 2 years ago

Hi, My bad, I was running the command in the Tools directory, now I am able to make the jsbsim bridge work by running that command (HEADLESS=1 ./jsbsim_bridge rascal -d /dev/ttyACM0 -s ~/src/Firmware/Tools/jsbsim_bridge/scene/LSZH.xml) from within the build directory (/PX4-Autopilot/build/px4_sitl_default/build_jsbsim_bridge). My pixhawk is detected on the serial port as shown in the image below.

image

QGC is also able to connect with pixhawk but i am unable to arm the vehicle as the vehicle launch position is not showing in QGC.

image

running dmesg in the MAVLINK console shows the follwing output.

image

PS: I replaced the px4_jsbsim_bridge files from this repo. (https://github.com/Auterion/px4-jsbsim-bridge/tree/f88764b091a8f5bc5f98893f07c63b56682a1420)

Jaeyoung-Lim commented 2 years ago

PS: I replaced the px4_jsbsim_bridge files from this repo. (https://github.com/Auterion/px4-jsbsim-bridge/tree/f88764b091a8f5bc5f98893f07c63b56682a1420)

@fahadmaqbool16 You can't do that it only works with this specific branch