-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Hardware-In-The-Loop simulation for JSBSim #28
base: master
Are you sure you want to change the base?
Conversation
9f4a187
to
7a7aff1
Compare
97bb7de
to
411ee67
Compare
@@ -63,6 +60,9 @@ class ConfigurationParser { | |||
std::string getInitScriptPath() { return _init_script_path; } | |||
std::string getModelName() { return _model_name; } | |||
int getRealtimeFactor() { return _realtime_factor; } | |||
bool getSerialEnabled() { return _serial_enabled; } | |||
int getBaudrate() { return _baudrate; } | |||
std::string getDevice() { return _device; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string getDevice() { return _device; } | |
const std::string& getDevice() const { return _device; } |
@@ -149,18 +149,35 @@ bool JSBSimBridge::SetFdmConfigs(ConfigurationParser &cfg) { | |||
} | |||
} | |||
|
|||
bool JSBSimBridge::SetMavlinkInterfaceConfigs(std::unique_ptr<MavlinkInterface> &interface, TiXmlHandle &config) { | |||
bool JSBSimBridge::SetMavlinkInterfaceConfigs(std::unique_ptr<MavlinkInterface> &interface, ConfigurationParser &cfg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool JSBSimBridge::SetMavlinkInterfaceConfigs(std::unique_ptr<MavlinkInterface> &interface, ConfigurationParser &cfg) { | |
bool JSBSimBridge::SetMavlinkInterfaceConfigs(std::unique_ptr<MavlinkInterface> &interface, const ConfigurationParser &cfg) { |
@@ -149,18 +149,35 @@ bool JSBSimBridge::SetFdmConfigs(ConfigurationParser &cfg) { | |||
} | |||
} | |||
|
|||
bool JSBSimBridge::SetMavlinkInterfaceConfigs(std::unique_ptr<MavlinkInterface> &interface, TiXmlHandle &config) { | |||
bool JSBSimBridge::SetMavlinkInterfaceConfigs(std::unique_ptr<MavlinkInterface> &interface, ConfigurationParser &cfg) { | |||
TiXmlHandle config = *cfg.XmlHandle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TiXmlHandle config = *cfg.XmlHandle(); | |
const TiXmlHandle& config = *cfg.XmlHandle(); |
@@ -199,7 +216,12 @@ void JSBSimBridge::Run() { | |||
} | |||
|
|||
// Receive and handle actuator controls | |||
_mavlink_interface->pollForMAVLinkMessages(); | |||
bool hil_mode_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always true (?)
d12eef0
to
774fa81
Compare
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 flag -d and -b. The bridge is configured to be run by HITL when the -d is provided. the baudrate is configured to be 921600 by default Enable HITL on mavlink interface This PR enables HITL on the mavlink interface Handle gcs udp port in config file
774fa81
to
a6faffc
Compare
Co-authored-by: Beat Küng <beat-kueng@gmx.net>
@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. |
@fahadmaqbool16 The pull request already explains how to test this PR, what additional information do you need? |
@Jaeyoung-Lim thanks for your reply, when I run
Nothing happens. |
@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 |
No, actually I was changing the directory to Tools to see if the command works, but it didn't. To clarify, I am
in the Tools directory, I get the error
if this command is not correct, can you please tell the correct command, |
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. 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. running dmesg in the MAVLINK console shows the follwing output. 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 |
interface->SetSerialEnabled(cfg.getSerialEnabled()); | ||
interface->SetDevice(cfg.getDevice()); | ||
interface->SetBaudrate(cfg.getBaudrate()); | ||
interface->SetHILStateLevel(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface->SetHILStateLevel(false); this fixes GPS Lock issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::shared_ptrJSBSim::FGInitialCondition initial_condition = _fdmexec->GetIC();
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-bridgeDescribe 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.
or to set the baudrate
The bridge is configured to be run with a HITL when the device path
-d
is provided. The baudrate is configured to be921600
by default, but can be also configured through a-b
flag.Test data / coverage
WIP
Additional context