Skip to content
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

How to add air flow disturbances, or similar forms of disturbances? #249

Open
LvXinyu2003 opened this issue Dec 12, 2024 · 2 comments
Open
Labels
question Further information is requested

Comments

@LvXinyu2003
Copy link

I want to verify the algorithm's ability to resist interference. How can I add air flow disturbances to a drone under gpy-bullet-drones conditions?

@JacopoPan JacopoPan added the question Further information is requested label Dec 15, 2024
@JacopoPan
Copy link
Member

JacopoPan commented Dec 15, 2024

you can add an additional

p.applyExternalForce(self.DRONE_IDS[nth_drone], 
                               4, 
                               forceObj=[x, y, z], 
                               posObj=[0, 0, 0], 
                               flags=p.LINK_FRAME, 
                               physicsClientId=self.CLIENT 
                               ) 

after line 711

def _physics(self,
rpm,
nth_drone
):
"""Base PyBullet physics implementation.
Parameters
----------
rpm : ndarray
(4)-shaped array of ints containing the RPMs values of the 4 motors.
nth_drone : int
The ordinal number/position of the desired drone in list self.DRONE_IDS.
"""
forces = np.array(rpm**2)*self.KF
torques = np.array(rpm**2)*self.KM
if self.DRONE_MODEL == DroneModel.RACE:
torques = -torques
z_torque = (-torques[0] + torques[1] - torques[2] + torques[3])
for i in range(4):
p.applyExternalForce(self.DRONE_IDS[nth_drone],
i,
forceObj=[0, 0, forces[i]],
posObj=[0, 0, 0],
flags=p.LINK_FRAME,
physicsClientId=self.CLIENT
)
p.applyExternalTorque(self.DRONE_IDS[nth_drone],
4,
torqueObj=[0, 0, z_torque],
flags=p.LINK_FRAME,
physicsClientId=self.CLIENT
)

@LvXinyu2003
Copy link
Author

you can add an additional

p.applyExternalForce(self.DRONE_IDS[nth_drone], 
                               4, 
                               forceObj=[x, y, z], 
                               posObj=[0, 0, 0], 
                               flags=p.LINK_FRAME, 
                               physicsClientId=self.CLIENT 
                               ) 

after line 711

def _physics(self,
rpm,
nth_drone
):
"""Base PyBullet physics implementation.
Parameters
----------
rpm : ndarray
(4)-shaped array of ints containing the RPMs values of the 4 motors.
nth_drone : int
The ordinal number/position of the desired drone in list self.DRONE_IDS.
"""
forces = np.array(rpm**2)*self.KF
torques = np.array(rpm**2)*self.KM
if self.DRONE_MODEL == DroneModel.RACE:
torques = -torques
z_torque = (-torques[0] + torques[1] - torques[2] + torques[3])
for i in range(4):
p.applyExternalForce(self.DRONE_IDS[nth_drone],
i,
forceObj=[0, 0, forces[i]],
posObj=[0, 0, 0],
flags=p.LINK_FRAME,
physicsClientId=self.CLIENT
)
p.applyExternalTorque(self.DRONE_IDS[nth_drone],
4,
torqueObj=[0, 0, z_torque],
flags=p.LINK_FRAME,
physicsClientId=self.CLIENT
)

I understand, thank you for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants