wuwushrek / sim_cf

34 stars 27 forks source link

Error when leveraging handler's `start_index` arg during spawn #12

Closed Arpafaucon closed 5 years ago

Arpafaucon commented 5 years ago

Overview

When experimenting with mixed-reality scenarios (some real drones, and some virtual ones), I noticed some use cases that aren't working properly. I'll describe them once I manage to reproduce them from scratch.

1 - Handler cannot handle start_index>1

Steps to reproduce

  1. Launch gazebo server
  2. Launch crazyflie_server
  3. Launch one cf2 instance: run_cfs 1
  4. Launch launch file below . It spawns one drone with prefix cf2, and registers it
    
    <?xml version="1.0"?>

### Observed behaviour
The `crazyflie_server` spawns a drone under `cf257`.
The gazebo server spawns a drone under `cf2`, and crashes.

greg@salade:~$ roslaunch sp_mate servers.launch ... logging to /home/greg/.ros/log/25ff6400-40e6-11e9-88c3-509a4c55508a/roslaunch-salade-679.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://salade:37484/

SUMMARY

PARAMETERS

NODES / crazyflie_server (crazyflie_driver/crazyflie_server) gazebo (gazebo_ros/gzserver)

ROS_MASTER_URI=http://localhost:11311

process[gazebo-1]: started with pid [702] process[crazyflie_server-2]: started with pid [707] Gazebo multi-robot simulator, version 7.0.0 Copyright (C) 2012-2016 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org

[ INFO] [1551973375.429592052]: Finished loading Gazebo ROS API Plugin. [Msg] Waiting for master. [ INFO] [1551973375.430879048]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting... [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [Msg] Publicized address: 129.104.49.16 [ INFO] [1551973376.719037912, 0.024000000]: waitForService: Service [/gazebo/set_physics_properties] is now available. [ INFO] [1551973376.788100173, 0.090000000]: Physics dynamic reconfigure ready. [Dbg] [gazebo_pressure_plugin.cpp:49] _model = cf2 [Dbg] [gazebo_magnetometer_plugin.cpp:252] ~/cf2/gazebo/magnetic_field [Dbg] [gazebo_cfHandler_plugin.cpp:26] Load() called. [Dbg] [gazebo_cfHandlerplugin.cpp:35] namespace = "/handler1/". [Dbg] [gazebo_cfHandler_plugin.cpp:91] LogBlocks size = 1 for Handler : handler1 [Dbg] [gazebo_cfHandler_plugin.cpp:106] Simulation is in SITL mode with address,port : INADDR_ANY , 19950 for Handler : handler1 [Dbg] [gazebo_cfHandler_plugin.cpp:155] Receiver, sender task created for Handler : handler1 [ INFO] [1551973397.511273488, 20.562000000]: [cf257] Creating CrazyflieROS services Segmentation fault (core dumped) [gazebo-1] process has died [pid 702, exit code 139, cmd /opt/ros/kinetic/lib/gazebo_ros/gzserver --verbose -e ode /home/greg/migws/src/sim_cf/crazyflie_gazebo/worlds/basic.world name:=gazebo log:=/home/greg/.ros/log/25ff6400-40e6-11e9-88c3-509a4c55508a/gazebo-1.log]. log file: /home/greg/.ros/log/25ff6400-40e6-11e9-88c3-509a4c55508a/gazebo-1*.log

tugayalperen commented 5 years ago

Hi, We encountered the same problem, the problem is about run_cfs.sh file. It always creates with IDs starting from 1, not caring about firstIndex, but it should care according to cfHandler plugin's source code. Here you can find modified verison of run_cfs.sh. You should give it a 4th argument, which stands for firstIndex. so usage should be:

./run_cfs.sh 4 19950 127.0.0.1 0 ./run_cfs.sh 4 19951 127.0.0.1 4

For 8 cf2 instance in total. run_cf_modified.txt

Arpafaucon commented 5 years ago

nice, thanks ! I can integrate that into a PR this week if you want

tugayalperen commented 5 years ago

If you think its appropriate, that is absolutely okay for me :+1:

Arpafaucon commented 5 years ago

fix proposed in PR #13

wuwushrek commented 5 years ago

This seems to be working, thanks !