Skip to content

Latest commit

 

History

History
143 lines (96 loc) · 5.27 KB

README.md

File metadata and controls

143 lines (96 loc) · 5.27 KB

Connect behavior trees with new Gazebo

  1. Commands to start the simulation in Asimovo:
 source /opt/ros/galactic/setup.bash
ign gazebo -s shapes.sdf -v 4
  1. Start the behavior tree script
 . install/setup.bash 
 ros2 run scenario_runner spawn_multiple
  1. To open the Gazebo viewer, you need to execute the code in the gazebo.ipynb notebook. You might need to start the websocket (?):
os.system('cd /gazebo && nohup ign launch -v 4 websocket.ign &')
  1. For debuggin you can check the list of services and models available in (ign) Gazebo:
ign service -l
ign model --list

Official tutorial on how to spawn models in (ignition) Gazebo: https://gazebosim.org/docs/garden/spawn_urdf

Service call: gz service -s /world/empty/create --reqtype gz.msgs.EntityFactory --reptype gz.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/path/to/model.urdf", name: "urdf_model"'

Monday:

  1. run behavior tree on Asimovo

  2. add spawn function and xml to the bt package - comment out the function

  3. call the service command from above

  4. add ign service to the header of the spawn function

  5. How to download a repo from git to Asimovo? Use https link, username + developer token

Build the ROS2 workspace: source /opt/ros/galactic/setup.bash colcon build or just a selected package e.g.: colcon build --packages-select scenario_runner Source packages: cd /user-data/ros_ws . install/setup.bash

Run the scenario: ros2 run scenario_runner scenario_runner

-create an xml with spawn node - copy from scenario_runner repo from github

-add these file to the CMakeLists

Command: $ ros2 run scenario_runner spawn_multiple

Reply: $ <model_name> model is spawned.

  1. Call the service:

Tab complete doesn't work on ign service call

Service call: gz service -s /world/empty/create --reqtype gz.msgs.EntityFactory --reptype gz.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/path/to/model.urdf", name: "urdf_model"'

ign service -s /world/shapes/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/user_data/ros_ws/src/behaviortrees_asimovo/scenario_runner/sdf/cylinder_model.sdf", name: "cylinder_model"'

I can't move the models in the viewer I can't check which ones are available

ign service -s /world/shapes/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 1000 --req 'sdf_filename: "/user_data/ros_ws/src/behaviortrees_asimovo/scenario_runner/sdf/cylinder_model.sdf", name: "cylinder_model"'

  1. add ign service to the header of the spawn function -doesn't work. We need to start the ros_ign bridge and publish on ROS service

  2. start a bridge ros2 run ros_ign_bridge parameter_bridge /model/vehicle_blue/cmd_vel@geometry_msgs/msg/Twist]ignition.msgs.Twist

  3. include the ROS service to the header

  1. call the bridge from terminal ros2 run ros_ign_bridge parameter_bridge /keyboard/keypress@std_msgs/msg/[email protected]

  2. call the ROS2 service from the node

  3. call the bridge from the node ros2 run ros_ign_bridge parameter_bridge /model/vehicle_blue/cmd_vel@geometry_msgs/msg/Twist]ignition.msgs.Twist ros2 run ros_ign_bridge parameter_bridge /world/shapes/create@ros_ign_interfaces/srv/SpawnEntity]ignition.msgs.EntityFactory ros2 run ros_ign_bridge parameter_bridge /world/shapes/create@ros_ign_interfaces/EntityFactory]ignition.msgs.EntityFactory

Not working - not implemented on foxy

"The bridge is currently implemented in C++. At this point there's no support for service calls. Its support is limited to only the following message types:" https://github.com/gazebosim/ros_gz/tree/foxy/ros_ign_bridge

The new version still has only one service implemented; worldcontrol https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge

Links: https://gazebosim.org/docs/garden/spawn_urdf https://docs.ros.org/en/galactic/Tutorials/Advanced/Simulators/Ignition.html https://gazebosim.org/docs/garden/ros2_integration https://answers.gazebosim.org//question/26037/how-to-spawn-sdf-object-in-ignition-gazebo/ https://github.com/gazebosim/ros_gz/tree/galactic/ros_ign_gazebo gazebosim/ros_gz#27 https://campus-rover.gitbook.io/lab-notebook/faq/spawn_model_terminal https://discourse.ros.org/t/spawning-a-robot-entity-using-a-node-with-gazebo-and-ros-2/9985 ros-simulation/gazebo_ros_pkgs#948 https://github.com/ros-simulation/gazebo_ros_pkgs/wiki/ROS-2-Migration:-Spawn-and-delete#spawn-entity-node https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge gazebosim/ros_gz#211

https://github.com/gezp/ros_ign_gazebo_manager/blob/main/src/ign_gazebo_manager.cpp https://github.com/gezp/ros_ign_gazebo_manager/blob/main/src/service_bridge.hpp