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

Clarification on Each Dimension's Meaning for ActionType.VEL #203

Open
input-0313 opened this issue Apr 14, 2024 · 3 comments
Open

Clarification on Each Dimension's Meaning for ActionType.VEL #203

input-0313 opened this issue Apr 14, 2024 · 3 comments
Labels
question Further information is requested

Comments

@input-0313
Copy link

@JacopoPan
Hello,
I'm currently working on a project using the gym-pybullet-drones environment, and I'm implementing drone control using the ActionType.VEL. I observed that the action space is defined with a size of 4 for each drone when this action type is used.
Could you clarify what each of the four dimensions in this action vector represents specifically for ActionType.VEL?

Additionally, in the "_preprocessAction" function, the target velocity vector is determined by the formula:
target_vel = self.SPEED_LIMIT * np.abs(target[3]) * v_unit_vector
Could you please explain why only the 4th dimension of the action vector is considered for the velocity's magnitude? Does this mean that the first three dimensions are intended for direction, and the fourth for scaling the velocity to the desired magnitude?

I'm trying to understand the underlying logic to ensure correct implementation and possibly make necessary adjustments for my project.
Thank you for your help!

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

Hi @input-0313

yes, you are correct, the first 3 components of the 4D action space in ActionType.VEL are interpreted as a direction in the 3D space, normalized to a unit vector, and then multiplied by the 4th component, interpreted as the desired velocity magnitude.

Of course, as you noted and if you prefer, you can modify this simply by re-implementing method _preprocessAction (part of the reason for doing this was simply to preserve the action space dimension across aviaries and not not change network architectures between learning example).

@input-0313
Copy link
Author

@JacopoPan Hello
Thanks for your previous reply. I'm implementing horizontal flight with the CF2X drone model, where the URDF file specifies a maximum flight speed of 30km/h. I've set the action space's xyz velocity thresholds at 8m/s before passing them into the controller, based on the speed unit in BaseRLAviary's "self.SPEED_LIMIT".

However, the actual drone speeds seem substantially lower than these set points. Does PyBullet have an intrinsic speed limit, or are there constraints on the velocities fed into the controller? Additionally, the drone occasionally flips or exhibits instability—might this be due to a need for PID tuning? If so, could you recommend some resources for PID parameter optimization?
Thank you for your time and assistance.

@JacopoPan
Copy link
Member

The control input (as individual motor RPMs) is computed from the desired velocity via the DSLPIDControl class in these lines. The resulting desired thrust will be limited by the fact that the target position is the same as the current one, you could try to increase the D_COEFF_FOR coefficients in the controller (the tracking of the desired velocity will be more aggressive but the instability might be exacerbated).

temp, _, _ = self.ctrl[k].computeControl(control_timestep=self.CTRL_TIMESTEP,
cur_pos=state[0:3],
cur_quat=state[3:7],
cur_vel=state[10:13],
cur_ang_vel=state[13:16],
target_pos=state[0:3], # same as the current position
target_rpy=np.array([0,0,state[9]]), # keep current yaw
target_vel=self.SPEED_LIMIT * np.abs(target_v[3]) * v_unit_vector # target the desired velocity vector
)

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