diff --git a/.gitignore b/.gitignore index 061dee1..dae5811 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ missing .tags* *.save* +# Python compiled files +*.pyc + # Hidden files ..* diff --git a/.vscode/settings.json b/.vscode/settings.json index 2bbb851..9a8f1ed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,4 +16,5 @@ }, "python.linting.pycodestyleEnabled": true, "python.linting.enabled": true, + "python.linting.pep8Enabled": true, } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..20dc256 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,34 @@ +# Changelog + +## v2.0.0-alpha + +- Quebra de compatibilidade com a v1.0.0 +- Tópicos recebem o valor do **torque em Nm** + - /robotX/vss_robot_left_controller/command + - /robotX/vss_robot_right_controller/command +- Padronização da nomenclatura com o VSSVision +- Simulação do atrito seco e viscoso no movimento das rodas +- Adição do ```effort_controllers``` como dependência + +### Problemas conhecidos + +- Propriedades físicas da bola +- A simulação falha em iniciar ocasionalmente + +## v1.0.0 - Iron Cup 2020 + +- Primeira versão funcional +- Projeto mecânico v1.1 - Thalles e Diego +- Controle dos motores pela **velocidade em rad/s** + - /robot_X/vss_robot_left_controller/command + - /robot_X/vss_robot_right_controller/command +- Ambientes de simulação + - Robô único + - Time de 3 + - Partida 3x3 +- Adição do ```velocity_controllers``` como dependência + +### Problemas conhecidos + +- Propriedades físicas da bola +- Comportamento dos motores ideal demais - longe da realidade diff --git a/CMakeLists.txt b/CMakeLists.txt index 23eca8a..a2cca42 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,6 @@ find_package(catkin REQUIRED) catkin_package() -# find_package(?roslaunch) - find_package(catkin REQUIRED COMPONENTS geometry_msgs roscpp @@ -16,7 +14,7 @@ find_package(catkin REQUIRED COMPONENTS gazebo_msgs ) -foreach(dir config launch meshes urdf) +foreach(dir config launch meshes urdf media worlds models) install(DIRECTORY ${dir}/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir}) endforeach(dir) diff --git a/README.md b/README.md index 4af759f..ff85728 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Projeto de simulação de um time IEEE VSS em um campo oficial em ROS utilizando - [Screenshots](#screenshots) - [Simulação de um robô](#simula%c3%a7%c3%a3o-de-um-rob%c3%b4) - [Simulação do time](#simula%c3%a7%c3%a3o-do-time) + - [Simulação da partida](#simula%c3%a7%c3%a3o-da-partida) - [TODO](#todo) ## Introdução @@ -65,8 +66,8 @@ geometry_msgs/Twist[] twist # desired twist in world frame Este pacote de simulação possui um script python que se increve no tópico do Gazebo e republica a informação nos 7 tópicos esperados pelo [ThunderVolt](https://github.com/ThundeRatz/vss_thundervolt): -- **/vision/robot_[0...2]** - Tópicos para os robôs do nosso time -- **/vision/foe_[0...2]** - Tópicos para os robôs adversários +- **/vision/robot[1...3]** - Tópicos para os robôs do nosso time +- **/vision/foe[1...3]** - Tópicos para os robôs adversários - **/vision/ball** - Tópico para a bola Todas as unidades estão no SI, distâncias estão em metros, ângulos estão em radianos, velocidade linear está em m/s e velocidade angular estã em rad/s @@ -112,10 +113,10 @@ A simulação é desenvolvida para ROS e Gazebo, é recomendável instalar ambos sudo apt install ros-melodic-desktop-full ``` -O projeto depende do pacote velocity_controllers dentro da biblioteca [ros_controllers](https://github.com/ros-controls/ros_controllers) e da biblioteca python [pygame](https://github.com/pygame/pygame). É possível instalar com ```apt-get``` +O projeto depende do pacote velocity_controllers e do effort-controllers dentro da biblioteca [ros_controllers](https://github.com/ros-controls/ros_controllers) e da biblioteca python [pygame](https://github.com/pygame/pygame). É possível instalar com ```apt-get``` ```bash -sudo apt install ros-melodic-velocity-controllers python-pygame +sudo apt install ros-melodic-velocity-controllers ros-melodic-effort-controllers python-pygame ``` Ou usando ```rosdep``` @@ -130,7 +131,7 @@ A simulação é construída em volta da versão 1.1 do robô de VSS do time Thu ## Cores no Gazebo -Para uma lista das cores disposníveis no Gazebo, confira o arquivo de configuração do [repo oficial](https://bitbucket.org/osrf/gazebo/src/gazebo11/media/materials/scripts/gazebo.material) +Para uma lista das cores disponíveis no Gazebo, confira o arquivo de configuração do [repo oficial](https://bitbucket.org/osrf/gazebo/src/gazebo11/media/materials/scripts/gazebo.material). Temos também um [script OGRE](./media/materials/scripts/vss.material) para a definição de cores customizadas ([ref](http://gazebosim.org/tutorials?tut=color_model) do Gazebo a respeito). ## Screenshots @@ -148,4 +149,5 @@ Para uma lista das cores disposníveis no Gazebo, confira o arquivo de configura ## TODO -Completar documentação. +- Completar documentação. +- Atualizar screenshots diff --git a/config/motor_effort.yaml b/config/motor_effort.yaml new file mode 100644 index 0000000..82375cb --- /dev/null +++ b/config/motor_effort.yaml @@ -0,0 +1,18 @@ +# Ref: +# https://answers.ros.org/question/326628/how-to-control-velocity-of-joints-in-gazebo-using-ros_controllers/ + +vss_robot_left_controller: + type: effort_controllers/JointEffortController + joint: roda_esq_joint + # pid: + # p: 100.0 + # i: 0.01 + # d: 10.0 + +vss_robot_right_controller: + type: effort_controllers/JointEffortController + joint: roda_dir_joint + # pid: + # p: 100.0 + # i: 0.01 + # d: 10.0 \ No newline at end of file diff --git a/config/vision_stat.yaml b/config/vision_stat.yaml new file mode 100644 index 0000000..1474d25 --- /dev/null +++ b/config/vision_stat.yaml @@ -0,0 +1,8 @@ +# Parameters for statistical error simulation +# See: vision_proxy.py +# +# var = data + error +# error = gaus(mu=0, ro=std_dev) + +vision: + std_dev: 0 diff --git a/launch/gazebo.launch b/launch/gazebo.launch index e6a0a53..3c853b5 100755 --- a/launch/gazebo.launch +++ b/launch/gazebo.launch @@ -10,7 +10,7 @@ https://github.com/ros/urdf_sim_tutorial --> - + @@ -28,20 +28,17 @@ https://github.com/ros/urdf_sim_tutorial --> - + - - - + + + diff --git a/launch/simulation_match.launch b/launch/simulation_match.launch index bbd31d5..9302cb2 100644 --- a/launch/simulation_match.launch +++ b/launch/simulation_match.launch @@ -6,6 +6,7 @@ + @@ -18,6 +19,7 @@ + diff --git a/launch/simulation_robot.launch b/launch/simulation_robot.launch index 1690f2d..4ffe748 100644 --- a/launch/simulation_robot.launch +++ b/launch/simulation_robot.launch @@ -6,6 +6,7 @@ + @@ -21,6 +22,7 @@ + diff --git a/launch/simulation_team.launch b/launch/simulation_team.launch index 6caf048..4119920 100644 --- a/launch/simulation_team.launch +++ b/launch/simulation_team.launch @@ -6,6 +6,7 @@ + @@ -18,6 +19,7 @@ + diff --git a/launch/spawn_match.launch b/launch/spawn_match.launch index 9a32d4e..d62d6a6 100644 --- a/launch/spawn_match.launch +++ b/launch/spawn_match.launch @@ -3,10 +3,13 @@ + + - + @@ -18,7 +21,7 @@ - + @@ -30,7 +33,7 @@ - + @@ -44,7 +47,7 @@ - + @@ -58,7 +61,7 @@ - + @@ -72,7 +75,7 @@ - + diff --git a/launch/spawn_robot.launch b/launch/spawn_robot.launch index 28bca3d..94c8764 100644 --- a/launch/spawn_robot.launch +++ b/launch/spawn_robot.launch @@ -27,18 +27,13 @@ http://wiki.ros.org/simulator_gazebo/Tutorials/Gazebo_ROS_API--> -urdf -model $(arg robot_name) -param robot_description" respawn="false" output="screen" /> - - - - - + file="$(find vss_simulation)/config/motor_effort.yaml" /> + + diff --git a/media/materials/scripts/vss.material b/media/materials/scripts/vss.material new file mode 100644 index 0000000..9fa58b5 --- /dev/null +++ b/media/materials/scripts/vss.material @@ -0,0 +1,14 @@ +import * from "grid.material" + +material VSS/Wine +{ + technique + { + pass ambient + { + ambient 0.07 0.45 0.00 1.00 + diffuse 0.07 0.45 0.00 1.00 + specular 0.1 0.1 0.1 1 1 + } + } +} \ No newline at end of file diff --git a/models/my_sun/model.config b/models/my_sun/model.config new file mode 100644 index 0000000..8fa8f8d --- /dev/null +++ b/models/my_sun/model.config @@ -0,0 +1,19 @@ + + + + Sun + 1.0 + model.sdf + + + + Felipe Gomes de Melo + felipe.gomes@thunderatz.org + + + + A directional light for the sun. + Taken from https://bitbucket.org/osrf/gazebo/src/gazebo11/models/sun/model.sdf + + diff --git a/models/my_sun/model.sdf b/models/my_sun/model.sdf new file mode 100644 index 0000000..94346a7 --- /dev/null +++ b/models/my_sun/model.sdf @@ -0,0 +1,16 @@ + + + + true + 2 2 10 0 0 0 + 0.8 0.8 0.8 1 + 0.2 0.2 0.2 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + diff --git a/models/golf_ball/model.config b/models/vss_ball/model.config similarity index 100% rename from models/golf_ball/model.config rename to models/vss_ball/model.config diff --git a/models/golf_ball/model.sdf b/models/vss_ball/model.sdf similarity index 80% rename from models/golf_ball/model.sdf rename to models/vss_ball/model.sdf index 7b2c8de..596929c 100644 --- a/models/golf_ball/model.sdf +++ b/models/vss_ball/model.sdf @@ -1,10 +1,10 @@ +Proprieties according to IEEE 3x3 rules --> - + @@ -56,20 +56,14 @@ Proprieties according to IEEE VSS 3x3 rules --> - 1 - 1 - 0 0 0 - 0 - 0 + 0.1 + 0.1 1 0 0 1 - - 0 - @@ -88,14 +82,6 @@ Proprieties according to IEEE VSS 3x3 rules --> 10 0 - - 1 - -0.01 - 0 - 0.2 - 1e+13 - 1 - diff --git a/models/vss_field/meshes/base_link.stl b/models/vss_field/meshes/base_link.stl new file mode 100755 index 0000000..2d33a84 Binary files /dev/null and b/models/vss_field/meshes/base_link.stl differ diff --git a/models/vss_field/meshes/field_link.stl b/models/vss_field/meshes/base_link_col.stl similarity index 100% rename from models/vss_field/meshes/field_link.stl rename to models/vss_field/meshes/base_link_col.stl diff --git a/models/vss_field/meshes/laterais_link.stl b/models/vss_field/meshes/laterais_link.stl index b8bca1d..1ee5fc0 100755 Binary files a/models/vss_field/meshes/laterais_link.stl and b/models/vss_field/meshes/laterais_link.stl differ diff --git a/models/vss_field/meshes/laterais_link_col.stl b/models/vss_field/meshes/laterais_link_col.stl new file mode 100755 index 0000000..b8bca1d Binary files /dev/null and b/models/vss_field/meshes/laterais_link_col.stl differ diff --git a/models/vss_field/model.config b/models/vss_field/model.config index 5f040c1..6f20d6c 100644 --- a/models/vss_field/model.config +++ b/models/vss_field/model.config @@ -2,7 +2,7 @@ VSS Field - 1.0 + 1.1 model.sdf @@ -14,4 +14,4 @@ A IEEE - Very Small Size Soccer used for 3x3 matches. URDF file and meshes were generated with SW2URDF extension, please see http://wiki.ros.org/sw_urdf_exporter - \ No newline at end of file + diff --git a/models/vss_field/model.sdf b/models/vss_field/model.sdf index 94bc92c..d7ca3ae 100644 --- a/models/vss_field/model.sdf +++ b/models/vss_field/model.sdf @@ -4,6 +4,9 @@ Commit Version: 1.5.1-0-g916b5db Build Version: 1.5.7152.31018 For more information, please see http://wiki.ros.org/sw_urdf_exporter--> + + @@ -12,28 +15,28 @@ https://bitbucket.org/osrf/gazebo/src/gazebo11/models/ground_plane/model.sdf --> 1 - + 0 0 0 0 0 0 0 0 0.01 0 0 0 - 4.6526 + 4.8995 - 0.50723 - -7.32956e-07 - 2.53149e-08 - 0.842188 - 3.64809e-08 - 1.34821 + 0.541513 + 5.91216e-07 + -5.64316e-09 + 0.271333 + 1.16883e-08 + 0.81109 - + 0 0 0 0 0 0 1 1 1 - model://vss_field/meshes/field_link.stl + model://vss_field/meshes/base_link_col.stl @@ -42,8 +45,8 @@ https://bitbucket.org/osrf/gazebo/src/gazebo11/models/ground_plane/model.sdf --> - 100 - 50 + 0.6 + 0.6 @@ -53,36 +56,22 @@ https://bitbucket.org/osrf/gazebo/src/gazebo11/models/ground_plane/model.sdf --> 20 - - + 0 0 0 0 0 0 1 1 1 - model://vss_field/meshes/laterais_link.stl + model://vss_field/meshes/laterais_link_col.stl - - - 0xffff - - - - 0.5 - 0.25 - - - - - 20 - - - 0 0 0 0 -0 0 + + + 0 0 0 0 0 0 1 1 1 - model://vss_field/meshes/field_link.stl + model://vss_field/meshes/base_link.stl @@ -113,6 +102,6 @@ https://bitbucket.org/osrf/gazebo/src/gazebo11/models/ground_plane/model.sdf --> - 0 0 0.01 0 0 0 + - \ No newline at end of file + diff --git a/package.xml b/package.xml index df5ff0c..c6527a5 100755 --- a/package.xml +++ b/package.xml @@ -1,6 +1,6 @@ vss_simulation - 1.0.0 + 2.0.0

Gazebo simulation package for VSS robots

This package contains configuration data, 3D models and launch files @@ -15,6 +15,7 @@ for vss_robot robot

roslaunch robot_state_publisher velocity_controllers + effort_controllers rviz joint_state_publisher gazebo diff --git a/scripts/keyboard_node.py b/scripts/keyboard_node.py index af6f2f9..1ca7816 100755 --- a/scripts/keyboard_node.py +++ b/scripts/keyboard_node.py @@ -30,7 +30,7 @@ ROBOTS = 3 # Namespace dos tópicos que iremos publicar -DEFAULT_NAMESPACE = "/robot_{}" +DEFAULT_NAMESPACE = "/robot{}" DEFAULT_DEBUG = False @@ -39,6 +39,7 @@ WHEEL_RADIUS = 0.030 # m ANG_VEL = LIN_VEL/WHEEL_RADIUS # rad/s +ANG_VEL = 0.1078 # Nm # Os comandos vão de -126 até 126 de modo que os bytes 0xFE e 0xFF # nunca são utilizados @@ -46,7 +47,7 @@ def getNamespace(number): - return DEFAULT_NAMESPACE.format(number) + return DEFAULT_NAMESPACE.format(number+1) def drawConsole(win, font, console): diff --git a/scripts/velocity_proxy.py b/scripts/velocity_proxy.py index 563c48e..f2759e0 100755 --- a/scripts/velocity_proxy.py +++ b/scripts/velocity_proxy.py @@ -2,7 +2,7 @@ # coding=utf-8 """ File: - velocity_conversion.py + velocity_proxy.py Description: Simple python routine to convert velocity message diff --git a/scripts/vision_proxy.py b/scripts/vision_proxy.py index ed7eb5b..a84c3a9 100755 --- a/scripts/vision_proxy.py +++ b/scripts/vision_proxy.py @@ -6,25 +6,61 @@ Description: Simple python routine to separe the information published - from gazebo into several topics + from gazebo into several topics. + We remove any "vss_" prefixes when creating the topic name + + Params: + - /vision/precision + - /vision/std_dev + + Topics: + - /vision/ball + - /vision/robot1 + - /vision/robot2 + - /vision/robot3 + - /vision/foe1 + - /vision/foe2 + - /vision/foe3 """ import rospy +import random +from math import sin, cos, pi from std_msgs.msg import String from gazebo_msgs.msg import ModelStates, ModelState -MODELS = ["ball", - "robot1", - "robot2", - "robot3", - "foe1", - "foe2", - "foe3"] +# We take out every "vss_" prefix from our models +MODELS_NAMES = ["vss_ball", + "robot1", + "robot2", + "robot3", + "foe1", + "foe2", + "foe3"] pubs = {} -for model in MODELS: - pubs[model] = rospy.Publisher("/vision/" + model, ModelState, queue_size=1) + +def clean_model_name(model): + if model.split("_")[0] == "vss": + model = "_".join(model.split("_")[1:]) + return model + +for model in MODELS_NAMES: + pubs[model] = rospy.Publisher("/vision/" + clean_model_name(model), + ModelState, queue_size=1) + + +def apply_noise(data): + std_dev = rospy.get_param("/vision/std_dev", 0) + + theta = random.uniform(0, pi) + radius = random.gauss(0, std_dev) + + data.position.x += radius*cos(theta) + data.position.y += radius*sin(theta) + + return data def callback(data): @@ -36,9 +72,9 @@ def callback(data): """ rospy.loginfo(rospy.get_caller_id() + " I heard %s", data.name) for i, model in enumerate(data.name): - if model in MODELS: + if model in MODELS_NAMES: msg = ModelState(model_name=model, - pose=data.pose[i], + pose=apply_noise(data.pose[i]), twist=data.twist[i]) pubs[model].publish(msg) diff --git a/urdf/hat_colors.xacro b/urdf/hat_colors.xacro new file mode 100644 index 0000000..8197aa9 --- /dev/null +++ b/urdf/hat_colors.xacro @@ -0,0 +1,28 @@ + + + + + + + + Gazebo/Black + + + + ${team_color} + + + + ${robot_color} + + + + ${robot_color} + + + + ${robot_color} + + + + \ No newline at end of file diff --git a/urdf/motor.xacro b/urdf/motor.xacro index 59b0fa8..fb343c1 100644 --- a/urdf/motor.xacro +++ b/urdf/motor.xacro @@ -19,9 +19,7 @@ - - - hardware_interface/VelocityJointInterface + hardware_interface/EffortJointInterface diff --git a/urdf/vss_robot.gazebo b/urdf/vss_robot.gazebo index 8864251..69427a8 100644 --- a/urdf/vss_robot.gazebo +++ b/urdf/vss_robot.gazebo @@ -7,6 +7,11 @@ + + + + + @@ -42,7 +47,12 @@ - /robot$(arg robot_number) + + /robot$(arg robot_number) + + + /foe$(arg robot_number) + \ No newline at end of file diff --git a/urdf/vss_robot.urdf b/urdf/vss_robot.urdf index 35079f5..84b977c 100755 --- a/urdf/vss_robot.urdf +++ b/urdf/vss_robot.urdf @@ -87,6 +87,11 @@ + + + + + @@ -140,6 +145,11 @@ + + + + + diff --git a/urdf/vss_team.xacro b/urdf/vss_team.xacro index 8ad0cb2..921d6db 100644 --- a/urdf/vss_team.xacro +++ b/urdf/vss_team.xacro @@ -5,23 +5,11 @@ + - - - Gazebo/Black - - - - Gazebo/Black - - - + - - Gazebo/Yellow - - Gazebo/White @@ -35,50 +23,23 @@ - - - - Gazebo/Black - - - - Gazebo/Purple - - - - - - - Gazebo/Black - - - - Gazebo/Red - - + + + - - Gazebo/Black - - - - Gazebo/Green - - + + - + + - - Gazebo/Blue - - Gazebo/Grey @@ -92,42 +53,18 @@ - - - - Gazebo/Black - - - - Gazebo/SkyBlue - - - - - - - Gazebo/Black - - - - Gazebo/Turquoise - - + + + - - Gazebo/Black - - - - Gazebo/Indigo - - + + - + diff --git a/worlds/vss_field.world b/worlds/vss_field.world index 24b5be2..88fdf33 100644 --- a/worlds/vss_field.world +++ b/worlds/vss_field.world @@ -10,13 +10,13 @@ - model://sun + model://my_sun - + @@ -26,7 +26,7 @@ 0 0 0.040 0 0 0 - model://golf_ball + model://vss_ball diff --git a/worlds/vss_field_top.world b/worlds/vss_field_top.world index 34482f9..e09213f 100644 --- a/worlds/vss_field_top.world +++ b/worlds/vss_field_top.world @@ -10,14 +10,13 @@ - 10.0 0 10.0 0 0 0 - model://sun + model://my_sun - + @@ -27,7 +26,7 @@ 0 0 0.040 0 0 0 - model://golf_ball + model://vss_ball