Replies: 1 comment 1 reply
-
I'm going to skip to the second part. You can switch directly from high level commands to low level commands. I'm going to suggest you test your setup with cmdPos first, as I know that works and is easier to get working than velocity based commands. I recommend using timeHelper.sleepForRate(Hz) instead of the normal sleep(), the advantage to sleepForRate is that it keeps the rate as consistent as possible, even if you loop contains other code that needs to run that takes non-zero time. Try something like this (I can't test this at the moment, so there might be some bugs, but it should be close...) cf.takeoff(0.5, 0.25)
timeHelper.sleep(0.5)
# Make a circle, assumes crazyflie starts at x=0, y=0
Hz = 20
time_scaling = 1/4
fx = lambda t: np.sin(t*time_scaling)
fy = lambda t: np.sin(t*time_scaling)
# Make a list of evenly spaced time values from 0 to 8pi (duration of circle)
timesteps = np.arange(0, 2*np.pi/time_scaling, 1/Hz)
for timestep in timesteps:
x = fx(timestep)
y = fy(timestep)
z = 0.5
yaw = 0
cf.cmdPos((x, y, z), yaw)
timeHelper.sleepForRate(Hz)
cf.notifySetpointsStop()
cf.land(0.0, 2.0) If you can get this to work, you can verify that low level commands do in fact work and the issue is with your usage/implementation of cmdVel. |
Beta Was this translation helpful? Give feedback.
-
Hi!
I found no implementation of the
cmd_vel_legacy
command in crazyswarm2, so I implemented one incrazyflie_py/crazyflie.py
based on crazyswarm1:However, I noticed that in
crazyflie_server.py
:In the above function, the pitch term is opposite to the msg value. This makes me wonder if I implemented the
pitch
term correctly incrazyflie.py
. Why is there a-
sign in the function?Also, I want to send
cmd_vel
commands after the drone stably takes off. In other words, I want to change from high-level control to low-level control mid-way. However, my crazyflie seems to ignore low-level commands and drops directly after taking off. How should I fix this? Or, is it possible to use low-level command directly after high-level commands? My code is as follows.Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions