USC-ACTLab / crazyswarm

A Large Quadcopter Swarm
MIT License
325 stars 318 forks source link

issue with testing hello_world.py and hover_swarm.launch #747

Closed jsuh9 closed 1 year ago

jsuh9 commented 1 year ago

Hi, I am following this tutorial (https://crazyswarm.readthedocs.io/en/latest/tutorials/tutorials.html).

My system is: Ubuntu 20.04.6 LTS / Ros-Noetic

I am testing a single crazyflie, and I think I followed configurations correctly according to the tutorial with the proper channel and ID (checked in cfclient), and specified them in the .yaml files.

When I run

roslaunch crazyswarm hover_swarm.launch

I get the following error:

    ... logging to /home/js65935/.ros/log/01405092-1aa9-11ee-97c2-4123cfa398a9/roslaunch-ase-a38131-lt-48081.log
    Checking log directory for disk usage. This may take a while.
    Press Ctrl-C to interrupt
    Done checking log file disk usage. Usage is <1GB.

    started roslaunch server http://ase-a38131-lt:42077/

    SUMMARY
    ========

    PARAMETERS
     * /crazyflieTypes/CF21SingleMarker/batteryVoltageWarning: 3.8
     * /crazyflieTypes/CF21SingleMarker/batteryVoltateCritical: 3.7
     * /crazyflieTypes/CF21SingleMarker/bigQuad: False
     * /crazyflieTypes/CF21SingleMarker/dynamicsConfiguration: 0
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/i_range_m_z: 1500
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/i_range_xy: 2.0
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/i_range_z: 0.4
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kR_xy: 70000
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kR_z: 60000
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kd_omega_rp: 200
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kd_xy: 0.2
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kd_z: 0.4
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/ki_m_z: 500
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/ki_xy: 0.05
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/ki_z: 0.05
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kp_xy: 0.4
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kp_z: 1.25
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kw_xy: 20000
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/kw_z: 12000
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/mass: 0.032
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/ctrlMel/massThrust: 132000
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/kalman/mNGyro_rollpitch: 0.1
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/kalman/mNGyro_yaw: 0.1
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/kalman/pNAcc_xy: 1.0
     * /crazyflieTypes/CF21SingleMarker/firmwareParams/kalman/pNAcc_z: 2.0
     * /crazyflieTypes/CF21SingleMarker/markerConfiguration: 3
     * /crazyflieTypes/default/batteryVoltageWarning: 3.8
     * /crazyflieTypes/default/batteryVoltateCritical: 3.7
     * /crazyflieTypes/default/bigQuad: False
     * /crazyflieTypes/default/dynamicsConfiguration: 0
     * /crazyflieTypes/default/firmwareParams/ctrlMel/i_range_m_z: 1500
     * /crazyflieTypes/default/firmwareParams/ctrlMel/i_range_xy: 2.0
     * /crazyflieTypes/default/firmwareParams/ctrlMel/i_range_z: 0.4
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kR_xy: 70000
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kR_z: 60000
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kd_omega_rp: 200
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kd_xy: 0.2
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kd_z: 0.4
     * /crazyflieTypes/default/firmwareParams/ctrlMel/ki_m_z: 500
     * /crazyflieTypes/default/firmwareParams/ctrlMel/ki_xy: 0.05
     * /crazyflieTypes/default/firmwareParams/ctrlMel/ki_z: 0.05
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kp_xy: 0.4
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kp_z: 1.25
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kw_xy: 20000
     * /crazyflieTypes/default/firmwareParams/ctrlMel/kw_z: 12000
     * /crazyflieTypes/default/firmwareParams/ctrlMel/mass: 0.032
     * /crazyflieTypes/default/firmwareParams/ctrlMel/massThrust: 132000
     * /crazyflieTypes/default/markerConfiguration: 0
     * /crazyflieTypes/defaultSingleMarker/batteryVoltageWarning: 3.8
     * /crazyflieTypes/defaultSingleMarker/batteryVoltateCritical: 3.7
     * /crazyflieTypes/defaultSingleMarker/bigQuad: False
     * /crazyflieTypes/defaultSingleMarker/dynamicsConfiguration: 0
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/i_range_m_z: 1500
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/i_range_xy: 2.0
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/i_range_z: 0.4
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kR_xy: 70000
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kR_z: 60000
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kd_omega_rp: 200
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kd_xy: 0.2
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kd_z: 0.4
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/ki_m_z: 500
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/ki_xy: 0.05
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/ki_z: 0.05
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kp_xy: 0.4
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kp_z: 1.25
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kw_xy: 20000
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/kw_z: 12000
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/mass: 0.032
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/ctrlMel/massThrust: 132000
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/kalman/mNGyro_rollpitch: 0.2
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/kalman/mNGyro_yaw: 0.1
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/kalman/pNAcc_xy: 4.0
     * /crazyflieTypes/defaultSingleMarker/firmwareParams/kalman/pNAcc_z: 8.0
     * /crazyflieTypes/defaultSingleMarker/markerConfiguration: 3
     * /crazyflieTypes/large/batteryVoltageWarning: 11.4
     * /crazyflieTypes/large/batteryVoltateCritical: 11.1
     * /crazyflieTypes/large/bigQuad: True
     * /crazyflieTypes/large/dynamicsConfiguration: 0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/i_range_m_z: 1500
     * /crazyflieTypes/large/firmwareParams/ctrlMel/i_range_xy: 2.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/i_range_z: 4.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kR_xy: 30000
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kR_z: 40000
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kd_omega_rp: 100
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kd_xy: 3.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kd_z: 3.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/ki_m_z: 500
     * /crazyflieTypes/large/firmwareParams/ctrlMel/ki_xy: 1.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/ki_z: 2.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kp_xy: 8.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kp_z: 8.0
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kw_xy: 9000
     * /crazyflieTypes/large/firmwareParams/ctrlMel/kw_z: 10000
     * /crazyflieTypes/large/firmwareParams/ctrlMel/mass: 0.38
     * /crazyflieTypes/large/firmwareParams/ctrlMel/massThrust: 5400
     * /crazyflieTypes/large/markerConfiguration: 2
     * /crazyflieTypes/medium/batteryVoltageWarning: 7.6
     * /crazyflieTypes/medium/batteryVoltateCritical: 7.4
     * /crazyflieTypes/medium/bigQuad: True
     * /crazyflieTypes/medium/dynamicsConfiguration: 0
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/i_range_m_z: 1500
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/i_range_xy: 2.0
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/i_range_z: 2.0
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kR_xy: 50000
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kR_z: 60000
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kd_omega_rp: 200
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kd_xy: 1.0
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kd_z: 1.0
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/ki_m_z: 500
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/ki_xy: 0.1
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/ki_z: 0.5
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kp_xy: 2.0
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kp_z: 3
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kw_xy: 16000
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/kw_z: 12000
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/mass: 0.11
     * /crazyflieTypes/medium/firmwareParams/ctrlMel/massThrust: 23000
     * /crazyflieTypes/medium/markerConfiguration: 1
     * /crazyflies: [{'channel': 80, ...
     * /crazyswarm_server/enable_logging: True
     * /crazyswarm_server/enable_logging_pose: True
     * /crazyswarm_server/enable_parameters: True
     * /crazyswarm_server/firmwareParams/commander/enHighLevel: 1
     * /crazyswarm_server/firmwareParams/kalman/resetEstimation: 1
     * /crazyswarm_server/firmwareParams/locSrv/extPosStdDev: 1e-3
     * /crazyswarm_server/firmwareParams/locSrv/extQuatStdDev: 0.05
     * /crazyswarm_server/firmwareParams/ring/effect: 16
     * /crazyswarm_server/firmwareParams/ring/headlightEnable: 0
     * /crazyswarm_server/firmwareParams/ring/solidBlue: 255
     * /crazyswarm_server/firmwareParams/ring/solidGreen: 0
     * /crazyswarm_server/firmwareParams/ring/solidRed: 0
     * /crazyswarm_server/firmwareParams/stabilizer/controller: 2
     * /crazyswarm_server/firmwareParams/stabilizer/estimator: 2
     * /crazyswarm_server/force_no_cache: False
     * /crazyswarm_server/genericLogTopicFrequencies: [10]
     * /crazyswarm_server/genericLogTopic_log1_Variables: ['stateEstimate.x...
     * /crazyswarm_server/genericLogTopics: ['log1']
     * /crazyswarm_server/motion_capture_host_name: vicon
     * /crazyswarm_server/motion_capture_type: none
     * /crazyswarm_server/object_tracking_type: libobjecttracker
     * /crazyswarm_server/print_latency: False
     * /crazyswarm_server/save_point_clouds: /dev/null
     * /crazyswarm_server/send_position_only: False
     * /crazyswarm_server/write_csvs: False
     * /crazyswarm_teleop/csv_file: /home/js65935/cra...
     * /crazyswarm_teleop/timescale: 0.8
     * /dynamicsConfigurations/0/maxFitnessScore: 0.001
     * /dynamicsCoarenfigurations/0/maxPitch: 1.4
     * /dynamicsConfigurations/0/maxPitchRate: 20.0
     * /dynamicsConfigurations/0/maxRoll: 1.4
     * /dynamicsConfigurations/0/maxRollRate: 20.0
     * /dynamicsConfigurations/0/maxXVelocity: 2.0
     * /dynamicsConfigurations/0/maxYVelocity: 2.0
     * /dynamicsConfigurations/0/maxYawRate: 10.0
     * /dynamicsConfigurations/0/maxZVelocity: 3.0
     * /joy/dev: /dev/input/js0
     * /markerConfigurations/0/numPoints: 4
     * /markerConfigurations/0/offset: [0.0, -0.01, -0.04]
     * /markerConfigurations/0/points/0: [0.0177184, 0.013...
     * /markerConfigurations/0/points/1: [-0.0262914, 0.05...
     * /markerConfigurations/0/points/2: [-0.0328889, -0.0...
     * /markerConfigurations/0/points/3: [0.0431307, -0.03...
     * /markerConfigurations/1/numPoints: 4
     * /markerConfigurations/1/offset: [0.0, 0.0, -0.03]
     * /markerConfigurations/1/points/0: [-0.00896228, -0....
     * /markerConfigurations/1/points/1: [-0.0156318, 0.09...
     * /markerConfigurations/1/points/2: [0.0461693, -0.08...
     * /markerConfigurations/1/points/3: [-0.0789959, -0.0...
     * /markerConfigurations/2/numPoints: 4
     * /markerConfigurations/2/offset: [0.0, 0.0, -0.06]
     * /markerConfigurations/2/points/0: [0.0558163, -0.00...
     * /markerConfigurations/2/points/1: [-0.0113941, 0.00...
     * /markerConfigurations/2/points/2: [-0.0306277, 0.05...
     * /markerConfigurations/2/points/3: [0.0535816, -0.04...
     * /markerConfigurations/3/numPoints: 1
     * /markerConfigurations/3/offset: [0.0, -0.01, -0.04]
     * /markerConfigurations/3/points/0: [0.0177184, 0.013...
     * /numDynamicsConfigurations: 1
     * /numMarkerConfigurations: 4
     * /rosdistro: noetic
     * /rosversion: 1.16.0

    NODES
      /
        crazyswarm_server (crazyswarm/crazyswarm_server)
        crazyswarm_teleop (crazyswarm/crazyswarm_teleop)
        joy (joy/joy_node)
        rviz (rviz/rviz)

    auto-starting new master
    process[master]: started with pid [48100]
    ROS_MASTER_URI=http://localhost:11311

    setting /run_id to 01405092-1aa9-11ee-97c2-4123cfa398a9
    process[rosout-1]: started with pid [48121]
    started core service [/rosout]
    process[crazyswarm_server-2]: started with pid [48128]
    process[joy-3]: started with pid [48129]
    process[crazyswarm_teleop-4]: started with pid [48134]
    process[rviz-5]: started with pid [48136]
    [ INFO] [1688502367.259236205]: Wait for services...
    [ INFO] [1688502367.260035880]: waitForService: Service [/emergency] has not been advertised, waiting...
    ch: 1
    [ INFO] [1688502367.300962782]: waitForService: Service [/emergency] is now available.
    [ INFO] [1688502367.301568803]: Manager ready.
    [ INFO] [1688502367.304189520]: Parsed crazyflies.yaml successfully.
    [ INFO] [1688502367.304805977]: Adding CF: cf1 (radio://0/80/2M/E7E7E7E701, cf1)...
    [ WARN] [1688502367.327483897]: Couldn't set gain on joystick force feedback: Bad file descriptor
    [ INFO] [1688502367.328454286]: Opened joystick: /dev/input/js0 (Microsoft X-Box 360 pad). deadzone_: 0.050000.
    [ INFO] [1688502367.338591921]: CF ctor: 0.033756 s
    [ INFO] [1688502367.343248814]: [cf1] ESTKALMAN: State out of bounds, resetting
    [ INFO] [1688502367.345615248]: [cf1] ESTKALMAN: State out of bounds, resetting
    [ INFO] [1688502367.347948814]: [cf1] ESTKALMAN: State out of bounds, resetting
    [ INFO] [1688502367.350271225]: [cf1] ESTKALMAN: State out of bounds, resetting
    [ INFO] [1688502367.351078131]: [cf1] Requesting parameters...
    [ INFO] [1688502367.358564629]: Found variables in cache.
    [ INFO] [1688502367.724367144]: [cf1] reqParamTOC: 0.385746 s (279 params)
    [ INFO] [1688502367.724385768]: [cf1] Requesting logging variables...
    [ INFO] [1688502367.726690758]: Found variables in cache.
    [ INFO] [1688502367.726987863]: [cf1] reqLogTOC: 0.002634 s
    terminate called after throwing an instance of 'std::runtime_error'
      what():  Could not find ctrltarget.x in log toc!
    [crazyswarm_server-2] process has died [pid 48128, exit code -6, cmd /home/js65935/crazyswarm/ros_ws/devel/lib/crazyswarm/crazyswarm_server __name:=crazyswarm_server __log:=/home/js65935/.ros/log/01405092-1aa9-11ee-97c2-4123cfa398a9/crazyswarm_server-2.log].
    log file: /home/js65935/.ros/log/01405092-1aa9-11ee-97c2-4123cfa398a9/crazyswarm_server-2*.log

I could get around this issue by changing a line within hover_swarm.launch, specifically,

  enable_logging: True    -->   enable_logging: False

I am not sure if this is critical for the hello_world.py to work properly but this was the only way I found to not get the error above. Are there other proper ways to get around this issue?

With this temporary fix, I was able to run hello_world.py, but I am not observing the expected behavior (as in the simulation). One of my crazyflies starts up but does not lift up vertically (and eventually crashes to the ground because it tries to fly horizontally). The other one starts up and lift up okay but starts drifting into one direction horizontally without staying in the same (X,Y) position. Also behavior is slightly different (for the same code hello_world.py) every time I re-start the crazyflies.

Is the hovering within hello_world.py an open-loop control? By the way, at the moment, I am not using any position estimation system (no vicon nor LPS setup yet).

Also, how can I stop the crazyflie (emergency stop) within the hover_swarm.launch? Sometimes it crashes badly and I am concerend about the damage.

Any help is appreciated, thank you in advance.

knmcguire commented 1 year ago

Hi!

I can help out with at least the logging part. Your script is giving an error because it is sayint that your crazyflie does not have the following log variable in the firmware: ctrltarget.x. Have you updated the Crazyflie firmware as the instructions indicate? https://crazyswarm.readthedocs.io/en/latest/configuration.html

The server needs to stay alive in order to run any other scripts so yes it is important.

And yes you need a positioning of some kind, Your Crazyflie will either not take off properly or crash to the ceiling. It is PID with a feedback loop so that is really necessary.

I believe that there is an emergency service in ROS that you can call upon?

Crazyswarm1 is no longer being maintained regurally so I do advise you to switch to Crazyswarm2 if you can. https://imrclab.github.io/crazyswarm2/

jsuh9 commented 1 year ago

Hello,

Thank you for clarifications!

I did update the firmware to the latest (July 2023 one) every time and it still gives me an error related to the log variable ctrltarget.x.

I had to set the logging to false in order to have the server stay alive. What does the logging do? Can I just use this solution (setting logging to false)?

On Wed, Jul 5, 2023 at 03:35 Kimberly McGuire @.***> wrote:

Hi!

I can help out with at least the logging part. Your script is giving an error because it is sayint that your crazyflie does not have the following log variable in the firmware: ctrltarget.x https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/api/logs/#ctrltargetx. Have you updated the Crazyflie firmware as the instructions indicate? https://crazyswarm.readthedocs.io/en/latest/configuration.html

The server needs to stay alive in order to run any other scripts so yes it is important.

And yes you need a positioning of some kind, Your Crazyflie will either not take off properly or crash to the ceiling. It is PID with a feedback loop so that is really necessary.

I believe that there is an emergency service in ROS that you can call upon?

Crazyswarm1 is no longer being maintained regurally so I do advise you to switch to Crazyswarm2 if you can. https://imrclab.github.io/crazyswarm2/

— Reply to this email directly, view it on GitHub https://github.com/USC-ACTLab/crazyswarm/issues/747#issuecomment-1621292421, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACTZZERM22MIUH4HFADYGADXOURN7ANCNFSM6AAAAAAZ6D2XTM . You are receiving this because you authored the thread.Message ID: @.***>

knmcguire commented 1 year ago

Hmm, it's not part of the logging variables that the launch file has initialized is it? Or else it is probably initialized as part of the python library api I recon

jsuh9 commented 1 year ago

Yes, it’s the line within the hover_launch file. I was directed to set it as true but gave me errors, so I just set it to false and the server then runs.

On Thu, Jul 6, 2023 at 13:42 Kimberly McGuire @.***> wrote:

Hmm, it's not part of the logging variables that the launch file has initialized is it? Or else it is probably initialized as part of the python library api I recon

— Reply to this email directly, view it on GitHub https://github.com/USC-ACTLab/crazyswarm/issues/747#issuecomment-1624152308, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACTZZEQ62G2TCB5Q6QXE2LDXO4BJ3ANCNFSM6AAAAAAZ6D2XTM . You are receiving this because you authored the thread.Message ID: @.***>

knmcguire commented 1 year ago

So, I won't be able to test this out myself, but if you are still having issues with this... I would perhaps suggest to try out Crazyswarm2 instead: https://github.com/IMRCLab/crazyswarm2. Crazyswarm(1) support is no longer updated and there will be more help available for Crazyswarm2 (which is based on ROS2)