├── jupyter-notebooks ├── img │ ├── cave.png │ └── maze.png ├── remoteApi.dll ├── aula11-planejamento-caminhos-bug.ipynb ├── aula08-controle-introducao.ipynb ├── aula07-locomocao-modelos-cinematicos.ipynb ├── aula09-controle-cinematico.ipynb ├── aula04-descricao-espacial-transformacoes-rigidas.ipynb ├── aula07-locomocao-modelos-cinematicos-zmq.ipynb ├── aula20-localizacao-markov.ipynb └── simConst.py ├── cenas-coppeliasim ├── aula03-bill-zmq.ttt ├── aula03-pioneer.ttt ├── aula07-pioneer.ttt ├── aula07-robotino.ttt ├── aula03-pioneer-zmq.ttt ├── aula11-bug-wall-follow.ttt ├── aula09-controle-pioneer.ttt ├── aula09-controle-robotino.ttt └── aula08-controle-introducao.ttt └── README.md /jupyter-notebooks/img/cave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/jupyter-notebooks/img/cave.png -------------------------------------------------------------------------------- /jupyter-notebooks/img/maze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/jupyter-notebooks/img/maze.png -------------------------------------------------------------------------------- /jupyter-notebooks/remoteApi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/jupyter-notebooks/remoteApi.dll -------------------------------------------------------------------------------- /cenas-coppeliasim/aula03-bill-zmq.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula03-bill-zmq.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula03-pioneer.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula03-pioneer.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula07-pioneer.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula07-pioneer.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula07-robotino.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula07-robotino.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula03-pioneer-zmq.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula03-pioneer-zmq.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula11-bug-wall-follow.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula11-bug-wall-follow.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula09-controle-pioneer.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula09-controle-pioneer.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula09-controle-robotino.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula09-controle-robotino.ttt -------------------------------------------------------------------------------- /cenas-coppeliasim/aula08-controle-introducao.ttt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verlab/dcc042-robotica-movel/HEAD/cenas-coppeliasim/aula08-controle-introducao.ttt -------------------------------------------------------------------------------- /jupyter-notebooks/aula11-planejamento-caminhos-bug.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Wall following" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "try:\n", 17 | " import sim\n", 18 | "except:\n", 19 | " print ('--------------------------------------------------------------')\n", 20 | " print ('\"sim.py\" could not be imported. This means very probably that')\n", 21 | " print ('either \"sim.py\" or the remoteApi library could not be found.')\n", 22 | " print ('Make sure both are in the same folder as this file,')\n", 23 | " print ('or appropriately adjust the file \"sim.py\"')\n", 24 | " print ('--------------------------------------------------------------')\n", 25 | " print ('')\n", 26 | "\n", 27 | "import time\n", 28 | "import numpy as np" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 2, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "name": "stdout", 38 | "output_type": "stream", 39 | "text": [ 40 | "Program started\n", 41 | "Connected to remote API server\n", 42 | "Program ended\n" 43 | ] 44 | } 45 | ], 46 | "source": [ 47 | "####################################################################################\n", 48 | "# #\n", 49 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 50 | "# #\n", 51 | "####################################################################################\n", 52 | "\n", 53 | "print ('Program started')\n", 54 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 55 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 56 | "\n", 57 | "if clientID!=-1:\n", 58 | " print ('Connected to remote API server')\n", 59 | "\n", 60 | " robotname = 'Pioneer_p3dx'\n", 61 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 62 | " \n", 63 | " returnCode, l_wheel = sim.simxGetObjectHandle(clientID, robotname + '_leftMotor', sim.simx_opmode_oneshot_wait)\n", 64 | " returnCode, r_wheel = sim.simxGetObjectHandle(clientID, robotname + '_rightMotor', sim.simx_opmode_oneshot_wait) \n", 65 | " \n", 66 | " # Handles para os sonares\n", 67 | " returnCode, sonar_front = sim.simxGetObjectHandle(clientID, robotname + '_ultrasonicSensor5', sim.simx_opmode_oneshot_wait)\n", 68 | " returnCode, sonar_right = sim.simxGetObjectHandle(clientID, robotname + '_ultrasonicSensor7', sim.simx_opmode_oneshot_wait)\n", 69 | " \n", 70 | " # Específico do robô \n", 71 | " L = 0.331\n", 72 | " r = 0.09751\n", 73 | " \n", 74 | " following = False\n", 75 | " \n", 76 | " t = 0\n", 77 | " # Lembrar de habilitar o 'Real-time mode'\n", 78 | " startTime=time.time()\n", 79 | " lastTime = startTime\n", 80 | " while t < 90:\n", 81 | " \n", 82 | " now = time.time()\n", 83 | " dt = now - lastTime\n", 84 | " \n", 85 | " # Fazendo leitura dos sensores\n", 86 | " returnCode, detected_front, point_front, *_ = sim.simxReadProximitySensor(clientID, sonar_front, sim.simx_opmode_oneshot_wait)\n", 87 | " returnCode, detected_right, point_right, *_ = sim.simxReadProximitySensor(clientID, sonar_right, sim.simx_opmode_oneshot_wait)\n", 88 | " \n", 89 | " # Velocidades iniciais\n", 90 | " v = .4\n", 91 | " w = 0\n", 92 | "\n", 93 | " obstacle_in_front = (detected_front and np.linalg.norm(point_front) < .5)\n", 94 | " obstacle_in_right = (detected_right and np.linalg.norm(point_right) < .5)\n", 95 | " \n", 96 | " # Controle\n", 97 | " if obstacle_in_front:\n", 98 | " v = 0\n", 99 | " w = np.deg2rad(30)\n", 100 | " following = True\n", 101 | " else: \n", 102 | " if obstacle_in_right:\n", 103 | " w = np.deg2rad(10)\n", 104 | " elif following:\n", 105 | " v = .1\n", 106 | " w = np.deg2rad(-30)\n", 107 | "\n", 108 | " # Cinemática Inversa\n", 109 | " wr = ((2.0*v) + (w*L))/(2.0*r)\n", 110 | " wl = ((2.0*v) - (w*L))/(2.0*r) \n", 111 | " \n", 112 | " # Enviando velocidades\n", 113 | " sim.simxSetJointTargetVelocity(clientID, l_wheel, wl, sim.simx_opmode_oneshot_wait)\n", 114 | " sim.simxSetJointTargetVelocity(clientID, r_wheel, wr, sim.simx_opmode_oneshot_wait)\n", 115 | " \n", 116 | " t = t + dt \n", 117 | " lastTime = now\n", 118 | " \n", 119 | " sim.simxSetJointTargetVelocity(clientID, r_wheel, 0, sim.simx_opmode_oneshot_wait)\n", 120 | " sim.simxSetJointTargetVelocity(clientID, l_wheel, 0, sim.simx_opmode_oneshot_wait)\n", 121 | " \n", 122 | " # Now close the connection to CoppeliaSim:\n", 123 | " sim.simxFinish(clientID)\n", 124 | " \n", 125 | "else:\n", 126 | " print ('Failed connecting to remote API server')\n", 127 | " \n", 128 | "print ('Program ended')" 129 | ] 130 | }, 131 | { 132 | "cell_type": "markdown", 133 | "metadata": {}, 134 | "source": [ 135 | "# Para praticar\n", 136 | "\n", 137 | "- Tente fazer a navegação ficar mais suave e rápida\n", 138 | "- Faça a implementação completa dos Bugs 0, 1 e 2" 139 | ] 140 | } 141 | ], 142 | "metadata": { 143 | "kernelspec": { 144 | "display_name": "Python 3", 145 | "language": "python", 146 | "name": "python3" 147 | }, 148 | "language_info": { 149 | "codemirror_mode": { 150 | "name": "ipython", 151 | "version": 3 152 | }, 153 | "file_extension": ".py", 154 | "mimetype": "text/x-python", 155 | "name": "python", 156 | "nbconvert_exporter": "python", 157 | "pygments_lexer": "ipython3", 158 | "version": "3.8.5" 159 | } 160 | }, 161 | "nbformat": 4, 162 | "nbformat_minor": 4 163 | } 164 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DCC042 - Robótica Móvel 2 | 3 | Nesse repositório encontram-se os Jupyter Notebooks e as cenas de simulação do CoppeliaSim utilizados ao longo da disciplina. 4 | 5 | ## Ementa 6 | 7 | História da Robótica. Descrição Espacial e Transformações. Espaço de configurações. Locomoção. Cinemática de robôs móveis. Controle. Navegação. Planejamento de caminhos. Sensores. Localização. Mapeamento. SLAM. Paradigmas robóticos. Sistemas multi-robôs. 8 | 9 | ## Objetivos 10 | 11 | Esta disciplina abordará os principais conceitos de Robótica Móvel. Serão vistos aspectos relacionados à locomoção, navegação, planejamento de caminhos, percepção, localização e mapeamento. Ao final, os alunos devem ser capazes de entender esses conceitos, bem como implementar pequenas aplicações em simuladores e plataformas robóticas reais, além de prosseguir no desenvolvimento de projetos de pesquisa. 12 | 13 | ## Conteúdo 14 | 15 | 16 | 17 | | Assunto | Aulas | Jupyter | CoppeliaSim | 18 | |:----------------------------------------------|:-----------------:|:--------------------:|:---------------:| 19 | | Apresentação do curso | [Vídeo](https://youtu.be/qWWKAMMnPs8) - [Slides](https://drive.google.com/file/d/16EcZqbMsq4w-gy1JuWJFkCLLmUiSxZv-/view?usp=sharing) | | | 20 | | História e Atualidades | [Vídeo](https://youtu.be/FtLzd2LY7T4) - [Slides](https://drive.google.com/file/d/14J9dALWPGVY1qzoSx3h9yJYQFTTQYXoc/view?usp=sharing) | | | 21 | | Ferramental | [Vídeo](https://youtu.be/Ohrau23GmQk) - [Slides](https://drive.google.com/file/d/1TmWJxVjGy_MqZljqCs07ESk3-qxtkvf3/view?usp=sharing)
[Slides (ZeroMQ)](https://drive.google.com/file/d/1JK3L6e6gW5_8ugxl0852i2t--U7WdP58/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula03-ferramental.ipynb)
[Notebook (ZeroMQ)](../main/jupyter-notebooks/aula03-ferramental-zmq.ipynb) | [Pioneer](../main/cenas-coppeliasim/aula03-pioneer.ttt)
[Bill (ZeroMQ)](../main/cenas-coppeliasim/aula03-bill-zmq.ttt)
[Pioneer (ZeroMQ)](../main/cenas-coppeliasim/aula03-pioneer-zmq.ttt) | 22 | | Descrição espacial e Transformações rígidas | [Vídeo](https://youtu.be/RDUKZt00-oI) - [Slides](https://drive.google.com/file/d/1Ra94gTtL0exznbURIjL_uKL8XHPn1wPY/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula04-descricao-espacial-transformacoes-rigidas.ipynb) | | 23 | | Transf. homogêneas e Espaço de configurações | [Vídeo](https://youtu.be/lJfxVbuBVkE) - [Slides](https://drive.google.com/file/d/15IFPS6twEb69NhkUpsWVy8iO73KGGfmc/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula05-transformacoes-homogeneas-espaco-configuracoes.ipynb) | | 24 | | Locomoção – Conceitos e Mecanismos | [Vídeo](https://youtu.be/wNkUOfk5HDw) - [Slides](https://drive.google.com/file/d/1_2BvW8f7oUDA3osTCsvNwyQMdT2Y-5uR/view?usp=sharing) | | | 25 | | Locomoção – Modelos cinemáticos | [Vídeo](https://youtu.be/P1PIQilYliQ) - [Slides](https://drive.google.com/file/d/1tCxXqrZ94_4FyKE8By_-FDkFWlM-3Z3A/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula07-locomocao-modelos-cinematicos.ipynb)
[Notebook (ZeroMQ)](../main/jupyter-notebooks/aula07-locomocao-modelos-cinematicos-zmq.ipynb) | [Robotino](../main/cenas-coppeliasim/aula07-robotino.ttt), [Pioneer](../main/cenas-coppeliasim/aula07-pioneer.ttt) | 26 | | Controle – Introdução | [Vídeo](https://youtu.be/Y-opiS_gjhk) - [Slides](https://drive.google.com/file/d/18t-rwkNsRynWjjyEvVNsCwFDWUrddkFI/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula08-controle-introducao.ipynb)
[Notebook (ZeroMQ)](../main/jupyter-notebooks/aula08-controle-introducao-zmq.ipynb) | [Cena](../main/cenas-coppeliasim/aula08-controle-introducao.ttt) | 27 | | Controle – Cinemático | [Vídeo](https://youtu.be/uAwjyo6P08I) - [Slides](https://drive.google.com/file/d/1EiuDr9O-1pc8rDJHCm_t_o8Age2TWfa3/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula09-controle-cinematico.ipynb)
[Notebook (ZeroMQ)](../main/jupyter-notebooks/aula09-controle-cinematico-zmq.ipynb) | [Robotino](../main/cenas-coppeliasim/aula09-controle-robotino.ttt), [Pioneer](../main/cenas-coppeliasim/aula09-controle-pioneer.ttt) | 28 | | Paradigmas Robóticos | [Vídeo](https://youtu.be/B15kbEPK0iM) - [Slides](https://drive.google.com/file/d/1kfAZYTFhwCkZRXScMjoG4s3FhgndvT4K/view?usp=sharing) | | | 29 | | Planejamento de caminhos – Bug Algorithms | [Vídeo](https://youtu.be/uto-IPidMyI) - [Slides](https://drive.google.com/file/d/1MzzdPFmfV-M4uVOgyvMPR_b67_d_zgPn/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula11-planejamento-caminhos-bug.ipynb)
[Notebook (ZeroMQ)](../main/jupyter-notebooks/aula11-planejamento-caminhos-bug-zmq.ipynb) | [Cena](../main/cenas-coppeliasim/aula11-bug-wall-follow.ttt) | 30 | | Planejamento de caminhos – Campos Potenciais | [Vídeo](https://youtu.be/GBr8b40LBNg) - [Slides](https://drive.google.com/file/d/1TXXX5yL48QkH6433cJhpIy6cIVFoBq-S/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula12-planejamento-caminhos-campos-potenciais.ipynb) | | 31 | | Planejamento de caminhos – Roadmaps | [Vídeo](https://youtu.be/1ct_BgMqkdc) - [Slides](https://drive.google.com/file/d/1TNHXz8neDaT6GEyJ2nyh9VWxrTQlTo01/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula13-planejamento-caminhos-roadmaps.ipynb) | | 32 | | Planejamento de caminhos – PRM/RRT | [Vídeo](https://youtu.be/aZgiuvmHNS4) - [Slides](https://drive.google.com/file/d/1ECXem_SeZesay4Ls4Ai42LgX234jCe4P/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula14-planejamento-caminhos-prm-rrt.ipynb) | | 33 | | Revisão de probabilidade | [Vídeo](https://youtu.be/3SvwmOXXi1w) - [Slides](https://drive.google.com/file/d/1nX6zDvroEoIIo1rR6fULrP31LxivSXEB/view?usp=sharing) | | | 34 | | Sensores | [Vídeo](https://youtu.be/QC0HdHgHysE) - [Slides](https://drive.google.com/file/d/1cmWfgl2JKZYVbHwoeCSxdnvuy6OXsp36/view?usp=sharing) | | | 35 | | Mapeamento – Introdução | [Vídeo](https://youtu.be/Yrqz9ZIAxDc) - [Slides](https://drive.google.com/file/d/17Q0EuDkXkmvvsWAWMej0v8rE88bV2YEs/view?usp=sharing) | | | 36 | | Mapeamento – Occupancy Grid | [Vídeo](https://youtu.be/aROLZ8zB-2Y) - [Slides](https://drive.google.com/file/d/1dvmsh0tcJsHPDyU2QR5MYszkSXD3rSTD/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula18-mapeamento-occupancy-grid.ipynb) | | 37 | | Localização – Kalman | [Vídeo](https://youtu.be/mXLwe9OEoeI) - [Slides](https://drive.google.com/file/d/1sIQxAWU0TLkwtRrEh1puKCvZAvKuRcJ7/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula19-localizacao-kalman.ipynb) | | 38 | | Localização – Markov | [Vídeo](https://youtu.be/dypoOHO_-eY) - [Slides](https://drive.google.com/file/d/1qUL4kXcz9-BzDdwK_bRsNt18-k6pmYzp/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula20-localizacao-markov.ipynb) | | 39 | | Localização – MCL | [Vídeo](https://youtu.be/oBPa0h8T9D8) - [Slides](https://drive.google.com/file/d/1UeICJJXd7UIcZot3jQyv2gRV4XfdHexk/view?usp=sharing) | [Notebook](../main/jupyter-notebooks/aula21-localizacao-mcl.ipynb) | | 40 | | SLAM - Introdução | [Vídeo](https://youtu.be/rKU7oabW3i4) - [Slides](https://drive.google.com/file/d/1KZoCjENHgTZZgVtssJTL9TIXiLS-waCN/view?usp=sharing) | | | 41 | | Sistemas multi-robôs | [Vídeo](https://youtu.be/pOSPOhdQkZI) - [Slides](https://drive.google.com/file/d/12GFMADLzJk3WcrmMLOj-MyE-pZ7V5CIg/view?usp=sharing) | | | 42 | -------------------------------------------------------------------------------- /jupyter-notebooks/aula08-controle-introducao.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 10, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "try:\n", 10 | " import sim\n", 11 | "except:\n", 12 | " print ('--------------------------------------------------------------')\n", 13 | " print ('\"sim.py\" could not be imported. This means very probably that')\n", 14 | " print ('either \"sim.py\" or the remoteApi library could not be found.')\n", 15 | " print ('Make sure both are in the same folder as this file,')\n", 16 | " print ('or appropriately adjust the file \"sim.py\"')\n", 17 | " print ('--------------------------------------------------------------')\n", 18 | " print ('')\n", 19 | "\n", 20 | "import time\n", 21 | "import numpy as np" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "# Bang-bang" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 12, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "name": "stdout", 38 | "output_type": "stream", 39 | "text": [ 40 | "Program started\n", 41 | "Connected to remote API server\n", 42 | "0 [-11.069377899169922, 0.9948067665100098, 0.19417336583137512]\n", 43 | "Program ended\n" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "####################################################################################\n", 49 | "# #\n", 50 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 51 | "# #\n", 52 | "####################################################################################\n", 53 | "\n", 54 | "print ('Program started')\n", 55 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 56 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 57 | "\n", 58 | "if clientID!=-1:\n", 59 | " print ('Connected to remote API server')\n", 60 | "\n", 61 | " robotname = 'Manta'\n", 62 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 63 | " \n", 64 | " returnCode, steerHandle = sim.simxGetObjectHandle(clientID, 'steer_joint', sim.simx_opmode_oneshot_wait)\n", 65 | " returnCode, motorHandle = sim.simxGetObjectHandle(clientID, 'motor_joint', sim.simx_opmode_oneshot_wait)\n", 66 | " \n", 67 | " motor_torque = 60\n", 68 | " returnCode = sim.simxSetJointForce(clientID, motorHandle, motor_torque, sim.simx_opmode_oneshot_wait)\n", 69 | " \n", 70 | " motor_velocity = 12\n", 71 | " returnCode = sim.simxSetJointTargetVelocity(clientID, motorHandle, motor_velocity, sim.simx_opmode_oneshot_wait)\n", 72 | " \n", 73 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 74 | " print(returnCode, robotPos)\n", 75 | " \n", 76 | " max_steer = np.deg2rad(10)\n", 77 | " \n", 78 | " # Lembrar de habilitar o 'Real-time mode'\n", 79 | " t = 0\n", 80 | " lastTime = time.time()\n", 81 | " while t < 25:\n", 82 | " \n", 83 | " now = time.time()\n", 84 | " dt = now - lastTime\n", 85 | " \n", 86 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_streaming + 10)\n", 87 | " #print(returnCode, robotPos)\n", 88 | " \n", 89 | " # Entrada de controle\n", 90 | " u = max_steer\n", 91 | " if robotPos[1] > 0:\n", 92 | " u = -max_steer\n", 93 | " \n", 94 | " returnCode = sim.simxSetJointTargetPosition(clientID, steerHandle, u, sim.simx_opmode_streaming + 10)\n", 95 | " \n", 96 | " t = t + dt \n", 97 | " lastTime = now \n", 98 | " \n", 99 | "\n", 100 | " motor_velocity = 0\n", 101 | " returnCode = sim.simxSetJointTargetVelocity(clientID, motorHandle, motor_velocity, sim.simx_opmode_oneshot_wait)\n", 102 | "\n", 103 | " # Now close the connection to CoppeliaSim:\n", 104 | " sim.simxFinish(clientID)\n", 105 | "else:\n", 106 | " print ('Failed connecting to remote API server')\n", 107 | " \n", 108 | "print ('Program ended')" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "# PID" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 21, 121 | "metadata": {}, 122 | "outputs": [ 123 | { 124 | "name": "stdout", 125 | "output_type": "stream", 126 | "text": [ 127 | "Program started\n", 128 | "Connected to remote API server\n", 129 | "0 [-11.039521217346191, 0.998039722442627, 0.19415727257728577]\n", 130 | "Program ended\n" 131 | ] 132 | } 133 | ], 134 | "source": [ 135 | "####################################################################################\n", 136 | "# #\n", 137 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 138 | "# #\n", 139 | "####################################################################################\n", 140 | "\n", 141 | "print ('Program started')\n", 142 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 143 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 144 | "\n", 145 | "if clientID!=-1:\n", 146 | " print ('Connected to remote API server')\n", 147 | "\n", 148 | " robotname = 'Manta'\n", 149 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 150 | " \n", 151 | " returnCode, steerHandle = sim.simxGetObjectHandle(clientID, 'steer_joint', sim.simx_opmode_oneshot_wait)\n", 152 | " returnCode, motorHandle = sim.simxGetObjectHandle(clientID, 'motor_joint', sim.simx_opmode_oneshot_wait)\n", 153 | " \n", 154 | " motor_torque = 60\n", 155 | " returnCode = sim.simxSetJointForce(clientID, motorHandle, motor_torque, sim.simx_opmode_oneshot_wait)\n", 156 | " \n", 157 | " motor_velocity = 12\n", 158 | " returnCode = sim.simxSetJointTargetVelocity(clientID, motorHandle, motor_velocity, sim.simx_opmode_oneshot_wait)\n", 159 | " \n", 160 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 161 | " print(returnCode, robotPos)\n", 162 | " \n", 163 | " max_steer = np.deg2rad(20)\n", 164 | " \n", 165 | " # Estado objetivo é y = 0\n", 166 | " setpoint = 0\n", 167 | " \n", 168 | " error = 0\n", 169 | " lastError = 0\n", 170 | " lastTime = 0\n", 171 | " cumError = 0\n", 172 | " \n", 173 | " # kp = .4, kd = .5, ki = .01\n", 174 | " # Lembrar de habilitar o 'Real-time mode'\n", 175 | " t = 0\n", 176 | " lastTime = time.time()\n", 177 | " while t < 25:\n", 178 | " \n", 179 | " time.sleep(0.005)\n", 180 | " \n", 181 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_streaming + 10)\n", 182 | " #print(returnCode, robotPos)\n", 183 | " \n", 184 | " now = time.time()\n", 185 | " dt = now - lastTime\n", 186 | " \n", 187 | " # Error \n", 188 | " error = setpoint - robotPos[1]\n", 189 | " dError = (error - lastError) / dt\n", 190 | " cumError += error * dt\n", 191 | " \n", 192 | " # Proporcional\n", 193 | " kp = .4\n", 194 | " up = kp*error\n", 195 | " \n", 196 | " # Derivativo\n", 197 | " kd = .5\n", 198 | " ud = kd*dError\n", 199 | " \n", 200 | " # Integral\n", 201 | " ki = .01\n", 202 | " ui = ki*cumError\n", 203 | " \n", 204 | " # Controller\n", 205 | " u = up + ud + ui\n", 206 | " \n", 207 | " # Limitando o valor para +/- max\n", 208 | " u = max(min(u, max_steer), -max_steer)\n", 209 | " \n", 210 | " returnCode = sim.simxSetJointTargetPosition(clientID, steerHandle, u, sim.simx_opmode_streaming + 10)\n", 211 | "\n", 212 | " t = t + dt \n", 213 | " lastTime = now \n", 214 | " lastError = error\n", 215 | "\n", 216 | " motor_velocity = 0\n", 217 | " returnCode = sim.simxSetJointTargetVelocity(clientID, motorHandle, motor_velocity, sim.simx_opmode_oneshot_wait)\n", 218 | "\n", 219 | " # Now close the connection to CoppeliaSim:\n", 220 | " sim.simxFinish(clientID)\n", 221 | "else:\n", 222 | " print ('Failed connecting to remote API server')\n", 223 | " \n", 224 | "print ('Program ended')" 225 | ] 226 | }, 227 | { 228 | "cell_type": "markdown", 229 | "metadata": {}, 230 | "source": [ 231 | "# Para praticar\n", 232 | "\n", 233 | "- Altere os ganhos e verifique o impacto de cada um no resultado final." 234 | ] 235 | } 236 | ], 237 | "metadata": { 238 | "kernelspec": { 239 | "display_name": "Python 3", 240 | "language": "python", 241 | "name": "python3" 242 | }, 243 | "language_info": { 244 | "codemirror_mode": { 245 | "name": "ipython", 246 | "version": 3 247 | }, 248 | "file_extension": ".py", 249 | "mimetype": "text/x-python", 250 | "name": "python", 251 | "nbconvert_exporter": "python", 252 | "pygments_lexer": "ipython3", 253 | "version": "3.8.5" 254 | } 255 | }, 256 | "nbformat": 4, 257 | "nbformat_minor": 4 258 | } 259 | -------------------------------------------------------------------------------- /jupyter-notebooks/aula07-locomocao-modelos-cinematicos.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 18, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "try:\n", 10 | " import sim\n", 11 | "except:\n", 12 | " print ('--------------------------------------------------------------')\n", 13 | " print ('\"sim.py\" could not be imported. This means very probably that')\n", 14 | " print ('either \"sim.py\" or the remoteApi library could not be found.')\n", 15 | " print ('Make sure both are in the same folder as this file,')\n", 16 | " print ('or appropriately adjust the file \"sim.py\"')\n", 17 | " print ('--------------------------------------------------------------')\n", 18 | " print ('')\n", 19 | " \n", 20 | "\n", 21 | "import time\n", 22 | "import numpy as np\n", 23 | "\n", 24 | "def Rz(theta):\n", 25 | " \n", 26 | " return np.array([[ np.cos(theta), -np.sin(theta), 0 ],\n", 27 | " [ np.sin(theta), np.cos(theta) , 0 ],\n", 28 | " [ 0 , 0 , 1 ]])" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "# Holonômico (robotino)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 24, 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "name": "stdout", 45 | "output_type": "stream", 46 | "text": [ 47 | "Program started\n", 48 | "Connected to remote API server\n", 49 | "==> 15.000776290893555 [ 2.88009644e-05 -9.99863434e-01] 0.014843940734821792\n", 50 | "Pos: [0.1772177666425705, -2.0062546730041504, 0.038924433290958405]\n", 51 | "Ori: [-9.93319898e-05 1.48095944e-02 -5.26440352e-01]\n", 52 | "Program ended\n" 53 | ] 54 | } 55 | ], 56 | "source": [ 57 | "####################################################################################\n", 58 | "# #\n", 59 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 60 | "# #\n", 61 | "####################################################################################\n", 62 | "\n", 63 | "print ('Program started')\n", 64 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 65 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 66 | "\n", 67 | "if clientID!=-1:\n", 68 | " print ('Connected to remote API server')\n", 69 | "\n", 70 | " robotname = 'robotino'\n", 71 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 72 | " \n", 73 | " returnCode, wheel1 = sim.simxGetObjectHandle(clientID, 'wheel0_joint', sim.simx_opmode_oneshot_wait)\n", 74 | " returnCode, wheel2 = sim.simxGetObjectHandle(clientID, 'wheel1_joint', sim.simx_opmode_oneshot_wait)\n", 75 | " returnCode, wheel3 = sim.simxGetObjectHandle(clientID, 'wheel2_joint', sim.simx_opmode_oneshot_wait)\n", 76 | " \n", 77 | " # Robotino\n", 78 | " L = 0.135 # Metros\n", 79 | " r = 0.040 # Metros\n", 80 | " \n", 81 | " # Cinemática Direta\n", 82 | " Mdir = np.array([[-r/np.sqrt(3), 0, r/np.sqrt(3)], [r/3, (-2*r)/3, r/3], [r/(3*L), r/(3*L), r/(3*L)]])\n", 83 | " \n", 84 | " q = np.array([0, 0, 0])\n", 85 | " \n", 86 | " # Lembrar de habilitar o 'Real-time mode'\n", 87 | " t = 0\n", 88 | " lastTime = time.time()\n", 89 | " while t <= 15:\n", 90 | " \n", 91 | " now = time.time()\n", 92 | " dt = now - lastTime\n", 93 | " \n", 94 | " # Cinemática Direta\n", 95 | " # u = [np.deg2rad(45), np.deg2rad(0), np.deg2rad(-45)]\n", 96 | " \n", 97 | " # Velocidade desejada (x, y, w) \n", 98 | " if t <= 5:\n", 99 | " qdot = np.array([.2, 0, np.deg2rad(10)])\n", 100 | " elif t <= 10: \n", 101 | " qdot = np.array([0, -.2, np.deg2rad(-10)])\n", 102 | " else:\n", 103 | " qdot = np.array([-.2, 0, 0])\n", 104 | " \n", 105 | " #qdot = np.array([0, .3, 0])\n", 106 | " \n", 107 | " # Cinemática Inversa\n", 108 | " # w1, w2, w3\n", 109 | " Minv = np.linalg.inv(Rz(q[2]) @ Mdir)\n", 110 | " u = Minv @ qdot\n", 111 | "\n", 112 | " # Enviando velocidades\n", 113 | " sim.simxSetJointTargetVelocity(clientID, wheel1, u[0], sim.simx_opmode_streaming)\n", 114 | " sim.simxSetJointTargetVelocity(clientID, wheel2, u[1], sim.simx_opmode_streaming)\n", 115 | " sim.simxSetJointTargetVelocity(clientID, wheel3, u[2], sim.simx_opmode_streaming) \n", 116 | " \n", 117 | " q = q + (Rz(q[2]) @ Mdir @ u)*dt\n", 118 | " \n", 119 | " t = t + dt \n", 120 | " lastTime = now \n", 121 | " \n", 122 | " print('==> ', t, q[:2], np.rad2deg(q[2]))\n", 123 | " \n", 124 | " returnCode, pos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait) \n", 125 | " print('Pos: ', pos)\n", 126 | "\n", 127 | " returnCode, ori = sim.simxGetObjectOrientation(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 128 | " print('Ori: ', np.rad2deg(ori))\n", 129 | " \n", 130 | " sim.simxSetJointTargetVelocity(clientID, wheel1, 0, sim.simx_opmode_oneshot_wait)\n", 131 | " sim.simxSetJointTargetVelocity(clientID, wheel2, 0, sim.simx_opmode_oneshot_wait)\n", 132 | " sim.simxSetJointTargetVelocity(clientID, wheel3, 0, sim.simx_opmode_oneshot_wait)\n", 133 | " \n", 134 | " # Now close the connection to CoppeliaSim:\n", 135 | " sim.simxFinish(clientID)\n", 136 | " \n", 137 | "else:\n", 138 | " print ('Failed connecting to remote API server')\n", 139 | " \n", 140 | "print ('Program ended')" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "# Não-holonômico (Pioneer - diferencial)" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 27, 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "name": "stdout", 157 | "output_type": "stream", 158 | "text": [ 159 | "Program started\n", 160 | "Connected to remote API server\n", 161 | "==> 10.000176191329956 [-4.00007048 0. ] 0.0\n", 162 | "Pos: [-0.08509187400341034, -1.576438546180725, 0.13864625990390778]\n", 163 | "Ori: [ 0.09061561 -0.07323384 45.73659959]\n", 164 | "Program ended\n" 165 | ] 166 | } 167 | ], 168 | "source": [ 169 | "####################################################################################\n", 170 | "# #\n", 171 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 172 | "# #\n", 173 | "####################################################################################\n", 174 | "\n", 175 | "print ('Program started')\n", 176 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 177 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 178 | "\n", 179 | "if clientID!=-1:\n", 180 | " print ('Connected to remote API server')\n", 181 | "\n", 182 | " robotname = 'Pioneer_p3dx'\n", 183 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 184 | " \n", 185 | " returnCode, l_wheel = sim.simxGetObjectHandle(clientID, robotname + '_leftMotor', sim.simx_opmode_oneshot_wait)\n", 186 | " returnCode, r_wheel = sim.simxGetObjectHandle(clientID, robotname + '_rightMotor', sim.simx_opmode_oneshot_wait) \n", 187 | " \n", 188 | " # Específico do robô\n", 189 | " # https://www.generationrobots.com/media/Pioneer3DX-P3DX-RevA.pdf\n", 190 | " # L = 0.381 # Metros\n", 191 | " # r = 0.0975 # Metros\n", 192 | " \n", 193 | " L = 0.331\n", 194 | " r = 0.09751\n", 195 | " \n", 196 | " # Velocidade desejada (linear, angular)\n", 197 | " v = .3\n", 198 | " w = np.deg2rad(10)\n", 199 | "\n", 200 | " # Cinemática Inversa\n", 201 | " wr = ((2.0*v) + (w*L))/(2.0*r)\n", 202 | " wl = ((2.0*v) - (w*L))/(2.0*r) \n", 203 | " u = np.array([wr, wl])\n", 204 | "\n", 205 | " # Enviando velocidades\n", 206 | " sim.simxSetJointTargetVelocity(clientID, l_wheel, wl, sim.simx_opmode_oneshot_wait)\n", 207 | " sim.simxSetJointTargetVelocity(clientID, r_wheel, wr, sim.simx_opmode_oneshot_wait)\n", 208 | " \n", 209 | " q = np.array([0, 0, 0])\n", 210 | " \n", 211 | " t = 0\n", 212 | " # Lembrar de habilitar o 'Real-time mode'\n", 213 | " startTime=time.time()\n", 214 | " lastTime = startTime\n", 215 | " while t < 10:\n", 216 | " \n", 217 | " now = time.time()\n", 218 | " dt = now - lastTime\n", 219 | "\n", 220 | " # Cinemática Direta\n", 221 | " Mdir = np.array([[r*np.cos(q[2])/2, r*np.cos(q[2])/2], [r*np.sin(q[2])/2, r*np.sin(q[2])/2], [r/L, -r/L]])\n", 222 | " q = q + (Mdir @ u)*dt\n", 223 | " \n", 224 | " t = t + dt \n", 225 | " lastTime = now\n", 226 | " \n", 227 | " print('==> ', t, q[:2], np.rad2deg(q[2]))\n", 228 | " \n", 229 | " returnCode, pos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait) \n", 230 | " print('Pos: ', pos)\n", 231 | "\n", 232 | " returnCode, ori = sim.simxGetObjectOrientation(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 233 | " print('Ori: ', np.rad2deg(ori)) \n", 234 | " \n", 235 | " sim.simxSetJointTargetVelocity(clientID, r_wheel, 0, sim.simx_opmode_oneshot_wait)\n", 236 | " sim.simxSetJointTargetVelocity(clientID, l_wheel, 0, sim.simx_opmode_oneshot_wait)\n", 237 | " \n", 238 | " # Now close the connection to CoppeliaSim:\n", 239 | " sim.simxFinish(clientID)\n", 240 | " \n", 241 | "else:\n", 242 | " print ('Failed connecting to remote API server')\n", 243 | " \n", 244 | "print ('Program ended')" 245 | ] 246 | }, 247 | { 248 | "cell_type": "markdown", 249 | "metadata": {}, 250 | "source": [ 251 | "# Para praticar\n", 252 | "\n", 253 | "- Tentar utilizar o modelo do youBot (Kuka) e fazer uma navegação/controle simples\n", 254 | "- Tentar utilizar um modelo do tipo Ackermann (e.g., Manta) e fazer uma navegação/controle simples" 255 | ] 256 | } 257 | ], 258 | "metadata": { 259 | "kernelspec": { 260 | "display_name": "Python 3", 261 | "language": "python", 262 | "name": "python3" 263 | }, 264 | "language_info": { 265 | "codemirror_mode": { 266 | "name": "ipython", 267 | "version": 3 268 | }, 269 | "file_extension": ".py", 270 | "mimetype": "text/x-python", 271 | "name": "python", 272 | "nbconvert_exporter": "python", 273 | "pygments_lexer": "ipython3", 274 | "version": "3.8.5" 275 | } 276 | }, 277 | "nbformat": 4, 278 | "nbformat_minor": 4 279 | } 280 | -------------------------------------------------------------------------------- /jupyter-notebooks/aula09-controle-cinematico.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "try:\n", 10 | " import sim\n", 11 | "except:\n", 12 | " print ('--------------------------------------------------------------')\n", 13 | " print ('\"sim.py\" could not be imported. This means very probably that')\n", 14 | " print ('either \"sim.py\" or the remoteApi library could not be found.')\n", 15 | " print ('Make sure both are in the same folder as this file,')\n", 16 | " print ('or appropriately adjust the file \"sim.py\"')\n", 17 | " print ('--------------------------------------------------------------')\n", 18 | " print ('')\n", 19 | "\n", 20 | "import numpy as np\n", 21 | "\n", 22 | "def Rz(theta):\n", 23 | " \n", 24 | " return np.array([[ np.cos(theta), -np.sin(theta), 0 ],\n", 25 | " [ np.sin(theta), np.cos(theta) , 0 ],\n", 26 | " [ 0 , 0 , 1 ]])" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": {}, 32 | "source": [ 33 | "# Holonomic control" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 5, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "name": "stdout", 43 | "output_type": "stream", 44 | "text": [ 45 | "Program started\n", 46 | "Connected to remote API server\n", 47 | "Program ended\n" 48 | ] 49 | } 50 | ], 51 | "source": [ 52 | "####################################################################################\n", 53 | "# #\n", 54 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 55 | "# #\n", 56 | "####################################################################################\n", 57 | "\n", 58 | "print ('Program started')\n", 59 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 60 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 61 | "\n", 62 | "if clientID!=-1:\n", 63 | " print ('Connected to remote API server')\n", 64 | "\n", 65 | " robotname = 'robotino'\n", 66 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 67 | " \n", 68 | " returnCode, wheel1 = sim.simxGetObjectHandle(clientID, 'wheel0_joint', sim.simx_opmode_oneshot_wait)\n", 69 | " returnCode, wheel2 = sim.simxGetObjectHandle(clientID, 'wheel1_joint', sim.simx_opmode_oneshot_wait)\n", 70 | " returnCode, wheel3 = sim.simxGetObjectHandle(clientID, 'wheel2_joint', sim.simx_opmode_oneshot_wait)\n", 71 | " \n", 72 | " # Robotino\n", 73 | " L = 0.135 # Metros\n", 74 | " r = 0.040 # Metros\n", 75 | " \n", 76 | " # Cinemática Direta\n", 77 | " Mdir = np.array([[-r/np.sqrt(3), 0, r/np.sqrt(3)], [r/3, (-2*r)/3, r/3], [r/(3*L), r/(3*L), r/(3*L)]])\n", 78 | " \n", 79 | " # Goal configuration (x, y, theta) \n", 80 | " qgoal = np.array([3, 3, np.deg2rad(90)])\n", 81 | " #qgoal = np.array([3, -3, np.deg2rad(-90)])\n", 82 | " #qgoal = np.array([0, 0, np.deg2rad(0)])\n", 83 | " \n", 84 | " # Frame que representa o Goal\n", 85 | " returnCode, goalFrame = sim.simxGetObjectHandle(clientID, 'Goal', sim.simx_opmode_oneshot_wait) \n", 86 | " returnCode = sim.simxSetObjectPosition(clientID, goalFrame, -1, [qgoal[0], qgoal[1], 0], sim.simx_opmode_oneshot_wait)\n", 87 | " returnCode = sim.simxSetObjectOrientation(clientID, goalFrame, -1, [0, 0, qgoal[2]], sim.simx_opmode_oneshot_wait)\n", 88 | "\n", 89 | " gain = np.array([[0.1, 0, 0], [0, 0.1, 0], [0, 0, 0.1]])\n", 90 | " #gain = np.array([[0.3, 0, 0], [0, 0.1, 0], [0, 0, 0.1]])\n", 91 | " \n", 92 | " # Lembrar de habilitar o 'Real-time mode'\n", 93 | " while True:\n", 94 | " \n", 95 | " returnCode, pos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait) \n", 96 | " returnCode, ori = sim.simxGetObjectOrientation(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 97 | " q = np.array([pos[0], pos[1], ori[2]])\n", 98 | " \n", 99 | " error = qgoal - q\n", 100 | " \n", 101 | " # Margem aceitável de distância\n", 102 | " if (np.linalg.norm(error[:2]) < 0.05):\n", 103 | " break\n", 104 | "\n", 105 | " # Controller\n", 106 | " qdot = gain @ error\n", 107 | " \n", 108 | " # Cinemática Inversa\n", 109 | " # w1, w2, w3\n", 110 | " Minv = np.linalg.inv(Rz(q[2]) @ Mdir)\n", 111 | " u = Minv @ qdot\n", 112 | "\n", 113 | " # Enviando velocidades\n", 114 | " sim.simxSetJointTargetVelocity(clientID, wheel1, u[0], sim.simx_opmode_streaming)\n", 115 | " sim.simxSetJointTargetVelocity(clientID, wheel2, u[1], sim.simx_opmode_streaming)\n", 116 | " sim.simxSetJointTargetVelocity(clientID, wheel3, u[2], sim.simx_opmode_streaming) \n", 117 | " \n", 118 | " sim.simxSetJointTargetVelocity(clientID, wheel1, 0, sim.simx_opmode_oneshot_wait)\n", 119 | " sim.simxSetJointTargetVelocity(clientID, wheel2, 0, sim.simx_opmode_oneshot_wait)\n", 120 | " sim.simxSetJointTargetVelocity(clientID, wheel3, 0, sim.simx_opmode_oneshot_wait)\n", 121 | " \n", 122 | " # Now close the connection to CoppeliaSim:\n", 123 | " sim.simxFinish(clientID)\n", 124 | " \n", 125 | "else:\n", 126 | " print ('Failed connecting to remote API server')\n", 127 | " \n", 128 | "print ('Program ended')" 129 | ] 130 | }, 131 | { 132 | "cell_type": "markdown", 133 | "metadata": {}, 134 | "source": [ 135 | "# Configuration (pose) control" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 8, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "name": "stdout", 145 | "output_type": "stream", 146 | "text": [ 147 | "Program started\n", 148 | "Connected to remote API server\n", 149 | "Program ended\n" 150 | ] 151 | } 152 | ], 153 | "source": [ 154 | "####################################################################################\n", 155 | "# #\n", 156 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 157 | "# #\n", 158 | "####################################################################################\n", 159 | "\n", 160 | "# Normalize angle to the range [-pi,pi)\n", 161 | "def normalizeAngle(angle):\n", 162 | " return np.mod(angle+np.pi, 2*np.pi) - np.pi\n", 163 | "\n", 164 | "print ('Program started')\n", 165 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 166 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 167 | "\n", 168 | "if clientID!=-1:\n", 169 | " print ('Connected to remote API server')\n", 170 | "\n", 171 | " robotname = 'Pioneer_p3dx'\n", 172 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 173 | " \n", 174 | " returnCode, robotLeftMotorHandle = sim.simxGetObjectHandle(clientID, robotname + '_leftMotor', sim.simx_opmode_oneshot_wait)\n", 175 | " returnCode, robotRightMotorHandle = sim.simxGetObjectHandle(clientID, robotname + '_rightMotor', sim.simx_opmode_oneshot_wait)\n", 176 | " \n", 177 | " # Goal configuration (x, y, theta)\n", 178 | " qgoal = np.array([2, -2, np.deg2rad(90)])\n", 179 | " #qgoal = np.array([-2, -4, np.deg2rad(180)])\n", 180 | " \n", 181 | " # Frame que representa o Goal\n", 182 | " returnCode, goalFrame = sim.simxGetObjectHandle(clientID, 'Goal', sim.simx_opmode_oneshot_wait) \n", 183 | " returnCode = sim.simxSetObjectPosition(clientID, goalFrame, -1, [qgoal[0], qgoal[1], 0], sim.simx_opmode_oneshot_wait)\n", 184 | " returnCode = sim.simxSetObjectOrientation(clientID, goalFrame, -1, [0, 0, qgoal[2]], sim.simx_opmode_oneshot_wait) \n", 185 | " \n", 186 | " # Específico do robô\n", 187 | " L = 0.331\n", 188 | " r = 0.09751\n", 189 | " maxv = 1.0\n", 190 | " maxw = np.deg2rad(45)\n", 191 | " \n", 192 | " rho = np.inf\n", 193 | " while rho > .05:\n", 194 | " \n", 195 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 196 | " returnCode, robotOri = sim.simxGetObjectOrientation(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait) \n", 197 | " robotConfig = np.array([robotPos[0], robotPos[1], robotOri[2]])\n", 198 | " \n", 199 | " dx, dy, dth = qgoal - robotConfig\n", 200 | " \n", 201 | " rho = np.sqrt(dx**2 + dy**2)\n", 202 | " alpha = normalizeAngle(-robotConfig[2] + np.arctan2(dy,dx))\n", 203 | " beta = normalizeAngle(qgoal[2] - np.arctan2(dy,dx))\n", 204 | " \n", 205 | " kr = 4 / 20\n", 206 | " ka = 8 / 20\n", 207 | " kb = -1.5 / 20\n", 208 | " \n", 209 | " # Alvo na parte de trás\n", 210 | " if abs(alpha) > np.pi/2:\n", 211 | " kr = -kr \n", 212 | " \n", 213 | " # Se não ajustar a direção muda\n", 214 | " alpha = normalizeAngle(alpha-np.pi)\n", 215 | " beta = normalizeAngle(beta-np.pi)\n", 216 | " \n", 217 | " v = kr*rho\n", 218 | " w = ka*alpha + kb*beta\n", 219 | " \n", 220 | " # Limit v,w to +/- max\n", 221 | " v = max(min(v, maxv), -maxv)\n", 222 | " w = max(min(w, maxw), -maxw) \n", 223 | " \n", 224 | " wr = ((2.0*v) + (w*L))/(2.0*r)\n", 225 | " wl = ((2.0*v) - (w*L))/(2.0*r)\n", 226 | " \n", 227 | " sim.simxSetJointTargetVelocity(clientID, robotRightMotorHandle, wr, sim.simx_opmode_oneshot_wait)\n", 228 | " sim.simxSetJointTargetVelocity(clientID, robotLeftMotorHandle, wl, sim.simx_opmode_oneshot_wait)\n", 229 | "\n", 230 | " sim.simxSetJointTargetVelocity(clientID, robotRightMotorHandle, 0, sim.simx_opmode_oneshot_wait)\n", 231 | " sim.simxSetJointTargetVelocity(clientID, robotLeftMotorHandle, 0, sim.simx_opmode_oneshot_wait)\n", 232 | "\n", 233 | " # Now close the connection to CoppeliaSim:\n", 234 | " sim.simxFinish(clientID)\n", 235 | " \n", 236 | "else:\n", 237 | " print ('Failed connecting to remote API server')\n", 238 | " \n", 239 | "print ('Program ended')" 240 | ] 241 | }, 242 | { 243 | "cell_type": "markdown", 244 | "metadata": {}, 245 | "source": [ 246 | "# Position control (\\[De Luca e Oriolo, 1994\\])" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 11, 252 | "metadata": {}, 253 | "outputs": [ 254 | { 255 | "name": "stdout", 256 | "output_type": "stream", 257 | "text": [ 258 | "Program started\n", 259 | "Connected to remote API server\n", 260 | "Program ended\n" 261 | ] 262 | } 263 | ], 264 | "source": [ 265 | "####################################################################################\n", 266 | "# #\n", 267 | "# LEMBRE-SE QUE A SIMULAÇÃO DEVE ESTAR EM EXECUÇÃO! #\n", 268 | "# #\n", 269 | "####################################################################################\n", 270 | "\n", 271 | "print ('Program started')\n", 272 | "sim.simxFinish(-1) # just in case, close all opened connections\n", 273 | "clientID=sim.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to CoppeliaSim\n", 274 | "\n", 275 | "if clientID!=-1:\n", 276 | " print ('Connected to remote API server')\n", 277 | "\n", 278 | " robotname = 'Pioneer_p3dx'\n", 279 | " returnCode, robotHandle = sim.simxGetObjectHandle(clientID, robotname, sim.simx_opmode_oneshot_wait) \n", 280 | " \n", 281 | " returnCode, robotLeftMotorHandle = sim.simxGetObjectHandle(clientID, robotname + '_leftMotor', sim.simx_opmode_oneshot_wait)\n", 282 | " returnCode, robotRightMotorHandle = sim.simxGetObjectHandle(clientID, robotname + '_rightMotor', sim.simx_opmode_oneshot_wait)\n", 283 | " \n", 284 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 285 | " returnCode, robotOri = sim.simxGetObjectOrientation(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 286 | " \n", 287 | " # Goal position (x, y)\n", 288 | " pgoal = np.array([2, -2])\n", 289 | " pgoal = np.array([0, 0])\n", 290 | " \n", 291 | " # Frame que representa o Goal\n", 292 | " returnCode, goalFrame = sim.simxGetObjectHandle(clientID, 'Goal', sim.simx_opmode_oneshot_wait) \n", 293 | " returnCode = sim.simxSetObjectPosition(clientID, goalFrame, -1, [pgoal[0], pgoal[1], 0], sim.simx_opmode_oneshot_wait)\n", 294 | " returnCode = sim.simxSetObjectOrientation(clientID, goalFrame, -1, [0, 0, 0], sim.simx_opmode_oneshot_wait) \n", 295 | " \n", 296 | " \n", 297 | " # Específico do robô\n", 298 | " # https://www.generationrobots.com/media/Pioneer3DX-P3DX-RevA.pdf\n", 299 | " L = 0.381\n", 300 | " r = 0.0975\n", 301 | " maxv = 1.0\n", 302 | " maxw = np.deg2rad(45)\n", 303 | " \n", 304 | " rho = np.inf\n", 305 | " while rho > .05:\n", 306 | " \n", 307 | " returnCode, robotPos = sim.simxGetObjectPosition(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait)\n", 308 | " returnCode, robotOri = sim.simxGetObjectOrientation(clientID, robotHandle, -1, sim.simx_opmode_oneshot_wait) \n", 309 | " robotConfig = np.array([robotPos[0], robotPos[1], robotOri[2]]) \n", 310 | " \n", 311 | " dx, dy = pgoal - robotConfig[:2]\n", 312 | " \n", 313 | " # Apenas para interromper o loop\n", 314 | " rho = np.sqrt(dx**2 + dy**2)\n", 315 | " \n", 316 | " kr = 1\n", 317 | " kt = 2\n", 318 | " \n", 319 | " v = kr*(dx*np.cos(robotConfig[2]) + dy*np.sin(robotConfig[2]))\n", 320 | " w = kt*(np.arctan2(dy,dx) - robotConfig[2])\n", 321 | " \n", 322 | " # Limit v,w to +/- max\n", 323 | " v = max(min(v, maxv), -maxv)\n", 324 | " w = max(min(w, maxw), -maxw) \n", 325 | " \n", 326 | " vr = ((2.0*v) + (w*L))/(2.0*r)\n", 327 | " vl = ((2.0*v) - (w*L))/(2.0*r)\n", 328 | " \n", 329 | " sim.simxSetJointTargetVelocity(clientID, robotRightMotorHandle, vr, sim.simx_opmode_oneshot_wait)\n", 330 | " sim.simxSetJointTargetVelocity(clientID, robotLeftMotorHandle, vl, sim.simx_opmode_oneshot_wait)\n", 331 | "\n", 332 | " sim.simxSetJointTargetVelocity(clientID, robotRightMotorHandle, 0, sim.simx_opmode_oneshot_wait)\n", 333 | " sim.simxSetJointTargetVelocity(clientID, robotLeftMotorHandle, 0, sim.simx_opmode_oneshot_wait)\n", 334 | "\n", 335 | " # Now close the connection to CoppeliaSim:\n", 336 | " sim.simxFinish(clientID)\n", 337 | " \n", 338 | "else:\n", 339 | " print ('Failed connecting to remote API server')\n", 340 | " \n", 341 | "print ('Program ended')" 342 | ] 343 | }, 344 | { 345 | "cell_type": "markdown", 346 | "metadata": {}, 347 | "source": [ 348 | "# Para praticar\n", 349 | "\n", 350 | "- Considerando um robô holonômico (Robotino, youBot), faça o controle de forma que ele consiga realizar um trajeto no formato de uma figura geométrica (e.g., triângulo, quadrado, etc).\n", 351 | "- Considerando um robô holonômico (Robotino, youBot), faça o controle de forma que ele consiga seguir uma curva genérica.\n", 352 | "- Considerando diferentes tipos de robôs (holonômico e não-holonômico), compare os diferentes trajetos necessários para visitar um conjunto de pontos aleatórios no ambiente." 353 | ] 354 | } 355 | ], 356 | "metadata": { 357 | "kernelspec": { 358 | "display_name": "Python 3", 359 | "language": "python", 360 | "name": "python3" 361 | }, 362 | "language_info": { 363 | "codemirror_mode": { 364 | "name": "ipython", 365 | "version": 3 366 | }, 367 | "file_extension": ".py", 368 | "mimetype": "text/x-python", 369 | "name": "python", 370 | "nbconvert_exporter": "python", 371 | "pygments_lexer": "ipython3", 372 | "version": "3.8.5" 373 | } 374 | }, 375 | "nbformat": 4, 376 | "nbformat_minor": 4 377 | } 378 | -------------------------------------------------------------------------------- /jupyter-notebooks/aula04-descricao-espacial-transformacoes-rigidas.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "import matplotlib.pyplot as plt" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# Representação" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "## Posição" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 9, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "data": { 34 | "text/plain": [ 35 | "(0.0, 5.0, 0.0, 5.0)" 36 | ] 37 | }, 38 | "execution_count": 9, 39 | "metadata": {}, 40 | "output_type": "execute_result" 41 | }, 42 | { 43 | "data": { 44 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAD8CAYAAABaQGkdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAOOklEQVR4nO3df4xddZ3G8efptKQystGks5W1tGPCpkQha3FSJE02LnENrIQ1JjQqoBDN/OGywXSj0cV/yIYQk43xDyHuqAjEqUgEIoFdd5tIJRiknRmKLdbdmC5gU0yHrBbKGAz1s3+cO7Ypc+eeO3N+fs/7lUw69/a0fjR9+nnO9x7BESEAaVpT9wAAykPAgYQRcCBhBBxIGAEHEkb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veyD0qajoiH6p4nr4j4naS9kq6sd5K+dki6pndfe7+kK2x/t96RlhcRx3o/Hpf0sLLb4yUVGXAeaS1J79Dq25IOR8RX655nENtjtt/W+/4tkj4o6Ze1DtVHRHwpIjZFxLiyP7M/jojrax6rL9ujvYNW2R6V9CFJfT8JKizgEfGGpMVHWg9LeiDHI621sf09SU9J2mr7qO1P1z3TMnZIukHZdjnQ+/q7uodaxvmSHrf9c2V/8e+JiMZ//NQSGyU9aftZSfskPRYRP+p3MY+qAgnjSTYgYQQcSBgBBxJGwIGEEXAgYQQcSBgBBxL2/2xPxLX0qHmHAAAAAElFTkSuQmCC\n", 45 | "text/plain": [ 46 | "
" 47 | ] 48 | }, 49 | "metadata": { 50 | "needs_background": "light" 51 | }, 52 | "output_type": "display_data" 53 | } 54 | ], 55 | "source": [ 56 | "# Definindo pois pontos (vetores)\n", 57 | "# Lembrando que os valores representam as componentes\n", 58 | "p = np.array([1, 2])\n", 59 | "q = np.array([4, 3])\n", 60 | "\n", 61 | "# Origem\n", 62 | "origin = np.array([0, 0])\n", 63 | "\n", 64 | "# Plotando os pontos e a representação vetorial\n", 65 | "plt.figure()\n", 66 | "plt.plot(p[0], p[1], 'ro')\n", 67 | "plt.quiver(*origin, *p, color='r', angles='xy', scale_units='xy', scale=1)\n", 68 | "\n", 69 | "plt.plot(q[0], q[1], 'bo')\n", 70 | "plt.quiver(*origin, *q, color='b', angles='xy', scale_units='xy', scale=1)\n", 71 | "\n", 72 | "plt.axis('scaled')\n", 73 | "plt.axis((0, 5, 0, 5))" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "## Direção" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 19, 86 | "metadata": {}, 87 | "outputs": [ 88 | { 89 | "name": "stdout", 90 | "output_type": "stream", 91 | "text": [ 92 | "[3 1]\n", 93 | "3.1622776601683795\n", 94 | "0.3217505543966422\n", 95 | "[0.9486833 0.31622777]\n" 96 | ] 97 | }, 98 | { 99 | "data": { 100 | "text/plain": [ 101 | "(0.0, 5.0, 0.0, 5.0)" 102 | ] 103 | }, 104 | "execution_count": 19, 105 | "metadata": {}, 106 | "output_type": "execute_result" 107 | }, 108 | { 109 | "data": { 110 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAD8CAYAAABaQGkdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAMWUlEQVR4nO3dbWxdhX3H8d/PsVPqNBOTZpqswXGrTcmqSluSC3vhaQ+oq9hApUiAYGGvKvlFRwWqRLUuSG2l8sJvqoJUpJkWbVW90jwUaWJbN6Q2YqgPwaaEkmYlHYsBEclBPEaePVP/9+LeQBxs32P7nHt8//l+JCu+znH4gfLl3HvuCTgiBCCnnroHAKgOgQOJETiQGIEDiRE4kBiBA4n1FjnI9mlJb0n6taS3I6JR5SgA5SgUeMufRcQrlS0BUDqeogOJucidbLb/R9JrkkLS30fE2BLHjEgakaQtW7bs2717d8lTAZw3OTn5SkQMtDuuaOC/HREv275C0mOSPhsRjy93fKPRiImJiVUNBlCc7cki18IKPUWPiJdbP05LekTS1eubB6AT2gZue4vtrec/l/QJSc9WPQzA+hW5iv5BSY/YPn/8P0XE9ytdBaAUbQOPiOcl/X4HtgAoGW+TAYkROJAYgQOJETiQGIEDiRE4kBiBA4kROJAYgQOJETiQGIEDiRE4kBiBA4kROJAYgQOJETiQGIEDiRE4kBiBA4kROJAYgQOJETiQGIEDiRE4kBiBA4kROJAYgQOJETiQGIEDiRE4kBiBA4kROJAYgQOJETiQGIEDiRUO3PYm2z+z/WiVgwCUZzVn8DslnaxqCIDyFQrc9g5J10n6RrVzAJSp6Bn8a5I+L2lhuQNsj9iesD1x9uzZMrYBWKe2gdu+XtJ0REyudFxEjEVEIyIaAwMDpQ0EsHZFzuDDk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Wn1T0smI+Grde9qxPWD78tbn75f0cUn/VeuoZUTEFyJiR0QMqfl79gcRcXvNs5Zle0vrQqtsb5H0CUnLvhNUWuAR8bak87e0npR0sMAtrbWx/R1JP5a0y/ZLtj9d96YVDEv6azXPLk+3Pv6y7lEr2C7ph7afUfNf/I9FxIZ/+6lLfFDSE7aPSzom6V8i4vvLHcytqkBi3MkGJEbgQGIEDiRG4EBiBA4kRuBAYgQOJPb/IYQhemowLaMAAAAASUVORK5CYII=\n", 111 | "text/plain": [ 112 | "
" 113 | ] 114 | }, 115 | "metadata": { 116 | "needs_background": "light" 117 | }, 118 | "output_type": "display_data" 119 | } 120 | ], 121 | "source": [ 122 | "v = q - p\n", 123 | "print(v)\n", 124 | "\n", 125 | "# Norma (magnitude)\n", 126 | "m = np.linalg.norm(v)\n", 127 | "print(m)\n", 128 | "\n", 129 | "# Orientação\n", 130 | "a = np.arctan2(v[1], v[0])\n", 131 | "print(a)\n", 132 | "\n", 133 | "# Vetor unitário (direção)\n", 134 | "u = v / m\n", 135 | "print(u)\n", 136 | "\n", 137 | "\n", 138 | "plt.figure()\n", 139 | "plt.plot(p[0], p[1], 'ro')\n", 140 | "plt.plot(q[0], q[1], 'bo')\n", 141 | "\n", 142 | "# Plotando o vetor deslocamento\n", 143 | "plt.quiver(*p, *v, color='k', angles='xy', scale_units='xy', scale=1)\n", 144 | "\n", 145 | "# Plotando o vetor direção\n", 146 | "plt.quiver(*p, *u, color='r', angles='xy', scale_units='xy', scale=1)\n", 147 | "\n", 148 | "plt.axis('scaled')\n", 149 | "plt.axis((0, 5, 0, 5))" 150 | ] 151 | }, 152 | { 153 | "cell_type": "markdown", 154 | "metadata": {}, 155 | "source": [ 156 | "## Referencial" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": 28, 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "data": { 166 | "text/plain": [ 167 | "(0.0, 5.0, 0.0, 5.0)" 168 | ] 169 | }, 170 | "execution_count": 28, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | }, 174 | { 175 | "data": { 176 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAD8CAYAAABaQGkdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAM5klEQVR4nO3cfYxVhZ3G8ecpzFLFl7ZxNC5IMV3EGLZie4Om7NqWvlFe3E23aUrabps0nX/A2LhNV2g39SWN7iZtzG79Y7E1a9Na042lW6aRLqFagi+lMwoqoqzLSiCYBXwBLCvy8ts/7kWJzsw9M3PuPff+5vtJJs4djuMj8uXce+4RR4QA5PSOqgcAaB0CBxIjcCAxAgcSI3AgMQIHEptc5CDbz0s6LOmEpOMRUWvlKADlKBR4w0cj4kDLlgAoHU/RgcRc5E422/8j6WVJIelfI2L1EMf0SeqTpKlTp37w0ksvLXkqgFMGBwcPRERvs+OKBv6nEbHX9vmS1ku6NiI2Dnd8rVaLgYGBUQ0GUJztwSLXwgo9RY+IvY2/7pO0RtK88c0D0A5NA7c91fbZpz6X9ElJT7V6GIDxK3IV/QJJa2yfOv6eiFjX0lUAStE08IjYKenyNmwBUDLeJgMSI3AgMQIHEiNwIDECBxIjcCAxAgcSI3AgMQIHEiNwIDECBxIjcCAxAgcSI3AgMQIHEiNwIDECBxIjcCAxAgcSI3AgMQIHEiNwIDECBxIjcCAxAgcSI3AgMQIHEiNwIDECBxIjcCAxAgcSI3AgMQIHEiNwIDECBxIrHLjtSbYft93fykEAyjOaM/h1kra3agiA8hUK3PZ0SYsl/bC1c5BFROhknKx6xoRX9Ax+u6RvShr2v5jtPtsDtgf2799fxjZ0sWcOPKOHdz9c9YwJr2ngtpdI2hcRgyMdFxGrI6IWEbXe3t7SBqI7rd2xVmufXVv1jAmvyBl8vqRrbD8v6V5JC2z/pKWr0PX6d/Sr/7+4Hlu1poFHxMqImB4R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xbWluo8Vr2Pkk/jYhfVL2nqIh4RdKDkhZWu2RY8yVd03hde6+kBbZ/Uu2kkUXE3sZf90lao/rL4yGVGTi3tLZI46LVjyRtj4jvV72nGdu9tt/V+PwMSR+X9Eylo4YRESsjYnpEzFT91+xvI+KLFc8alu2pjQutsj1V0iclDftOUGmBR8RxSaduad0u6ecFbmmtjO2fSXpE0mzbe2x/tepNI5gv6Uuqn122ND4WVT1qBBdKesD2E6r/xr8+Ijr+7acucYGkTba3Stos6dcRsW64g7lVFUiMO9mAxAgcSIzAgcQIHEiMwIHECBxIjMCBxP4fehx0yqjmiNEAAAAASUVORK5CYII=\n", 177 | "text/plain": [ 178 | "
" 179 | ] 180 | }, 181 | "metadata": { 182 | "needs_background": "light" 183 | }, 184 | "output_type": "display_data" 185 | } 186 | ], 187 | "source": [ 188 | "# Matriz de rotação em relação a Z\n", 189 | "def Rz(theta):\n", 190 | " \n", 191 | " return np.array([[ np.cos(theta), -np.sin(theta), 0 ],\n", 192 | " [ np.sin(theta), np.cos(theta) , 0 ],\n", 193 | " [ 0 , 0 , 1 ]])\n", 194 | "\n", 195 | "\n", 196 | "# Plota um referencial no plano\n", 197 | "def plot_frame(Porg, R, c=None):\n", 198 | " \n", 199 | " axis_size = 1.0 \n", 200 | " axes = axis_size*R\n", 201 | " \n", 202 | " x_axis = np.array(axes[0:2,0])\n", 203 | " y_axis = np.array(axes[0:2,1])\n", 204 | " \n", 205 | " if c == None:\n", 206 | " c = ['r', 'g']\n", 207 | " \n", 208 | " # X\n", 209 | " plt.quiver(*Porg[0:2], *x_axis, color=c[0], angles='xy', scale_units='xy', scale=1)\n", 210 | " \n", 211 | " # Y\n", 212 | " plt.quiver(*Porg[0:2], *y_axis, color=c[1], angles='xy', scale_units='xy', scale=1)\n", 213 | " \n", 214 | " \n", 215 | "plt.figure()\n", 216 | "\n", 217 | "# Frame A\n", 218 | "Porg = np.array([2, 1, 0]) \n", 219 | "R = Rz(np.deg2rad(45))\n", 220 | "plot_frame(Porg, R)\n", 221 | "\n", 222 | "# Frame B\n", 223 | "Porg = np.array([3, 3, 0]) \n", 224 | "R = Rz(np.deg2rad(0))\n", 225 | "plot_frame(Porg, R)\n", 226 | "\n", 227 | "plt.axis('scaled')\n", 228 | "plt.axis((0, 5, 0, 5))" 229 | ] 230 | }, 231 | { 232 | "cell_type": "markdown", 233 | "metadata": {}, 234 | "source": [ 235 | "# Mapeamento" 236 | ] 237 | }, 238 | { 239 | "cell_type": "markdown", 240 | "metadata": {}, 241 | "source": [ 242 | "## Translação" 243 | ] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": 5, 248 | "metadata": {}, 249 | "outputs": [ 250 | { 251 | "name": "stdout", 252 | "output_type": "stream", 253 | "text": [ 254 | "[11 5 5]\n" 255 | ] 256 | } 257 | ], 258 | "source": [ 259 | "pb = np.array([4, 3, 5])\n", 260 | "\n", 261 | "pa_borg = np.array([7, 2, 0])\n", 262 | "\n", 263 | "pa = pb + pa_borg\n", 264 | "print(pa)" 265 | ] 266 | }, 267 | { 268 | "cell_type": "markdown", 269 | "metadata": {}, 270 | "source": [ 271 | "## Rotação" 272 | ] 273 | }, 274 | { 275 | "cell_type": "code", 276 | "execution_count": 6, 277 | "metadata": {}, 278 | "outputs": [ 279 | { 280 | "name": "stdout", 281 | "output_type": "stream", 282 | "text": [ 283 | "[-1. 1.73205081 0. ]\n", 284 | "[-1. 1.73205081 0. ]\n", 285 | "[-1. 1.73205081 0. ]\n" 286 | ] 287 | } 288 | ], 289 | "source": [ 290 | "pb = np.array([0, 2, 0])\n", 291 | "\n", 292 | "theta = np.deg2rad(30)\n", 293 | "\n", 294 | "# Qual operador de multiplicação utilizar?\n", 295 | "# https://blog.finxter.com/numpy-matmul-operator/\n", 296 | "\n", 297 | "pa = Rz(theta).dot(pb)\n", 298 | "print(pa)\n", 299 | "\n", 300 | "pa = np.matmul(Rz(theta), pb)\n", 301 | "print(pa)\n", 302 | "\n", 303 | "pa = Rz(theta) @ pb\n", 304 | "print(pa)" 305 | ] 306 | }, 307 | { 308 | "cell_type": "markdown", 309 | "metadata": {}, 310 | "source": [ 311 | "## Euler angles" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": 26, 317 | "metadata": {}, 318 | "outputs": [ 319 | { 320 | "name": "stdout", 321 | "output_type": "stream", 322 | "text": [ 323 | "[[ 4.32978028e-17 -5.00000000e-01 8.66025404e-01]\n", 324 | " [ 7.07106781e-01 6.12372436e-01 3.53553391e-01]\n", 325 | " [-7.07106781e-01 6.12372436e-01 3.53553391e-01]]\n", 326 | "1.5707963267948966 1.5707963267948966\n", 327 | "0.7853981633974483 0.7853981633974483\n", 328 | "1.0471975511965976 1.0471975511965976\n" 329 | ] 330 | } 331 | ], 332 | "source": [ 333 | "def Rx(theta):\n", 334 | " \n", 335 | " return np.array([[ 1, 0 , 0 ],\n", 336 | " [ 0, np.cos(theta),-np.sin(theta)],\n", 337 | " [ 0, np.sin(theta), np.cos(theta)]])\n", 338 | " \n", 339 | "def Ry(theta):\n", 340 | " \n", 341 | " return np.array([[ np.cos(theta), 0, np.sin(theta)],\n", 342 | " [ 0 , 1, 0 ],\n", 343 | " [-np.sin(theta), 0, np.cos(theta)]])\n", 344 | "\n", 345 | "\n", 346 | "alpha = np.pi/2\n", 347 | "beta = np.pi/4\n", 348 | "gamma = np.pi/3\n", 349 | "\n", 350 | "R = Rz(alpha) @ Ry(beta) @ Rx(gamma)\n", 351 | "print(R)\n", 352 | "\n", 353 | "cB = np.sqrt(R[0,0]**2 + R[1,0]**2)\n", 354 | "\n", 355 | "# Obtendo os Euler Angles a partir da matriz\n", 356 | "beta_calc = np.arctan2(-R[2,0], cB)\n", 357 | "alpha_calc = np.arctan2(R[1,0]/cB, R[0,0]/cB)\n", 358 | "gamma_calc = np.arctan2(R[2,1]/cB, R[2,2]/cB)\n", 359 | "\n", 360 | "print(alpha, alpha_calc)\n", 361 | "print(beta, beta_calc)\n", 362 | "print(gamma, gamma_calc)" 363 | ] 364 | }, 365 | { 366 | "cell_type": "markdown", 367 | "metadata": {}, 368 | "source": [ 369 | "## Translação + Rotação" 370 | ] 371 | }, 372 | { 373 | "cell_type": "code", 374 | "execution_count": 8, 375 | "metadata": {}, 376 | "outputs": [ 377 | { 378 | "name": "stdout", 379 | "output_type": "stream", 380 | "text": [ 381 | "[ 9.09807621 12.56217783 0. ]\n" 382 | ] 383 | } 384 | ], 385 | "source": [ 386 | "pb = np.array([3, 7, 0])\n", 387 | "\n", 388 | "pa_borg = np.array([10, 5, 0])\n", 389 | "\n", 390 | "theta = np.deg2rad(30)\n", 391 | "pa = Rz(theta) @ pb + pa_borg\n", 392 | "print(pa)" 393 | ] 394 | }, 395 | { 396 | "cell_type": "markdown", 397 | "metadata": {}, 398 | "source": [ 399 | "# Para praticar\n", 400 | "\n", 401 | "- Faça diferentes testes alterando os valores dos pontos, translação e rotação\n", 402 | "- Nos exempplos, plote os pontos e seus respectivos sistemas de coordenadas\n", 403 | "- Plote a representação vetorial dos pontos resultantes dos exemplos (igual aos slides)" 404 | ] 405 | } 406 | ], 407 | "metadata": { 408 | "kernelspec": { 409 | "display_name": "Python 3", 410 | "language": "python", 411 | "name": "python3" 412 | }, 413 | "language_info": { 414 | "codemirror_mode": { 415 | "name": "ipython", 416 | "version": 3 417 | }, 418 | "file_extension": ".py", 419 | "mimetype": "text/x-python", 420 | "name": "python", 421 | "nbconvert_exporter": "python", 422 | "pygments_lexer": "ipython3", 423 | "version": "3.8.5" 424 | } 425 | }, 426 | "nbformat": 4, 427 | "nbformat_minor": 4 428 | } 429 | -------------------------------------------------------------------------------- /jupyter-notebooks/aula07-locomocao-modelos-cinematicos-zmq.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import time\n", 10 | "import numpy as np\n", 11 | "\n", 12 | "from coppeliasim_zmqremoteapi_client import RemoteAPIClient \n", 13 | "\n", 14 | "def Rz(theta):\n", 15 | " \n", 16 | " return np.array([[ np.cos(theta), -np.sin(theta), 0 ],\n", 17 | " [ np.sin(theta), np.cos(theta) , 0 ],\n", 18 | " [ 0 , 0 , 1 ]])" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "metadata": {}, 24 | "source": [ 25 | "# Holonômico (robotino)" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 4, 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "name": "stdout", 35 | "output_type": "stream", 36 | "text": [ 37 | "Starting robot control loop...\n", 38 | "Simulation time: 0.05 [s]\n", 39 | "Simulation time: 0.10 [s]\n", 40 | "Simulation time: 0.15 [s]\n", 41 | "Simulation time: 0.20 [s]\n", 42 | "Simulation time: 0.25 [s]\n", 43 | "Simulation time: 0.30 [s]\n", 44 | "Simulation time: 0.35 [s]\n", 45 | "Simulation time: 0.40 [s]\n", 46 | "Simulation time: 0.45 [s]\n", 47 | "Simulation time: 0.50 [s]\n", 48 | "Simulation time: 0.55 [s]\n", 49 | "Simulation time: 0.60 [s]\n", 50 | "Simulation time: 0.65 [s]\n", 51 | "Simulation time: 0.70 [s]\n", 52 | "Simulation time: 0.75 [s]\n", 53 | "Simulation time: 0.80 [s]\n", 54 | "Simulation time: 0.85 [s]\n", 55 | "Simulation time: 0.90 [s]\n", 56 | "Simulation time: 0.95 [s]\n", 57 | "Simulation time: 1.00 [s]\n", 58 | "Simulation time: 1.05 [s]\n", 59 | "Simulation time: 1.10 [s]\n", 60 | "Simulation time: 1.15 [s]\n", 61 | "Simulation time: 1.20 [s]\n", 62 | "Simulation time: 1.25 [s]\n", 63 | "Simulation time: 1.30 [s]\n", 64 | "Simulation time: 1.35 [s]\n", 65 | "Simulation time: 1.40 [s]\n", 66 | "Simulation time: 1.45 [s]\n", 67 | "Simulation time: 1.50 [s]\n", 68 | "Simulation time: 1.55 [s]\n", 69 | "Simulation time: 1.60 [s]\n", 70 | "Simulation time: 1.65 [s]\n", 71 | "Simulation time: 1.70 [s]\n", 72 | "Simulation time: 1.75 [s]\n", 73 | "Simulation time: 1.80 [s]\n", 74 | "Simulation time: 1.85 [s]\n", 75 | "Simulation time: 1.90 [s]\n", 76 | "Simulation time: 1.95 [s]\n", 77 | "Simulation time: 2.00 [s]\n", 78 | "Simulation time: 2.05 [s]\n", 79 | "Simulation time: 2.10 [s]\n", 80 | "Simulation time: 2.15 [s]\n", 81 | "Simulation time: 2.20 [s]\n", 82 | "Simulation time: 2.25 [s]\n", 83 | "Simulation time: 2.30 [s]\n", 84 | "Simulation time: 2.35 [s]\n", 85 | "Simulation time: 2.40 [s]\n", 86 | "Simulation time: 2.45 [s]\n", 87 | "Simulation time: 2.50 [s]\n", 88 | "Simulation time: 2.55 [s]\n", 89 | "Simulation time: 2.60 [s]\n", 90 | "Simulation time: 2.65 [s]\n", 91 | "Simulation time: 2.70 [s]\n", 92 | "Simulation time: 2.75 [s]\n", 93 | "Simulation time: 2.80 [s]\n", 94 | "Simulation time: 2.85 [s]\n", 95 | "Simulation time: 2.90 [s]\n", 96 | "Simulation time: 2.95 [s]\n", 97 | "Simulation time: 3.00 [s]\n", 98 | "Simulation time: 3.05 [s]\n", 99 | "Simulation time: 3.10 [s]\n", 100 | "Simulation time: 3.15 [s]\n", 101 | "Simulation time: 3.20 [s]\n", 102 | "Simulation time: 3.25 [s]\n", 103 | "Simulation time: 3.30 [s]\n", 104 | "Simulation time: 3.35 [s]\n", 105 | "Simulation time: 3.40 [s]\n", 106 | "Simulation time: 3.45 [s]\n", 107 | "Simulation time: 3.50 [s]\n", 108 | "Simulation time: 3.55 [s]\n", 109 | "Simulation time: 3.60 [s]\n", 110 | "Simulation time: 3.65 [s]\n", 111 | "Simulation time: 3.70 [s]\n", 112 | "Simulation time: 3.75 [s]\n", 113 | "Simulation time: 3.80 [s]\n", 114 | "Simulation time: 3.85 [s]\n", 115 | "Simulation time: 3.90 [s]\n", 116 | "Simulation time: 3.95 [s]\n", 117 | "Simulation time: 4.00 [s]\n", 118 | "Simulation time: 4.05 [s]\n", 119 | "Simulation time: 4.10 [s]\n", 120 | "Simulation time: 4.15 [s]\n", 121 | "Simulation time: 4.20 [s]\n", 122 | "Simulation time: 4.25 [s]\n", 123 | "Simulation time: 4.30 [s]\n", 124 | "Simulation time: 4.35 [s]\n", 125 | "Simulation time: 4.40 [s]\n", 126 | "Simulation time: 4.45 [s]\n", 127 | "Simulation time: 4.50 [s]\n", 128 | "Simulation time: 4.55 [s]\n", 129 | "Simulation time: 4.60 [s]\n", 130 | "Simulation time: 4.65 [s]\n", 131 | "Simulation time: 4.70 [s]\n", 132 | "Simulation time: 4.75 [s]\n", 133 | "Simulation time: 4.80 [s]\n", 134 | "Simulation time: 4.85 [s]\n", 135 | "Simulation time: 4.90 [s]\n", 136 | "Simulation time: 4.95 [s]\n", 137 | "Simulation time: 5.00 [s]\n", 138 | "Simulation time: 5.05 [s]\n", 139 | "Simulation time: 5.10 [s]\n", 140 | "Simulation time: 5.15 [s]\n", 141 | "Simulation time: 5.20 [s]\n", 142 | "Simulation time: 5.25 [s]\n", 143 | "Simulation time: 5.30 [s]\n", 144 | "Simulation time: 5.35 [s]\n", 145 | "Simulation time: 5.40 [s]\n", 146 | "Simulation time: 5.45 [s]\n", 147 | "Simulation time: 5.50 [s]\n", 148 | "Simulation time: 5.55 [s]\n", 149 | "Simulation time: 5.60 [s]\n", 150 | "Simulation time: 5.65 [s]\n", 151 | "Simulation time: 5.70 [s]\n", 152 | "Simulation time: 5.75 [s]\n", 153 | "Simulation time: 5.80 [s]\n", 154 | "Simulation time: 5.85 [s]\n", 155 | "Simulation time: 5.90 [s]\n", 156 | "Simulation time: 5.95 [s]\n", 157 | "Simulation time: 6.00 [s]\n", 158 | "Simulation time: 6.05 [s]\n", 159 | "Simulation time: 6.10 [s]\n", 160 | "Simulation time: 6.15 [s]\n", 161 | "Simulation time: 6.20 [s]\n", 162 | "Simulation time: 6.25 [s]\n", 163 | "Simulation time: 6.30 [s]\n", 164 | "Simulation time: 6.35 [s]\n", 165 | "Simulation time: 6.40 [s]\n", 166 | "Simulation time: 6.45 [s]\n", 167 | "Simulation time: 6.50 [s]\n", 168 | "Simulation time: 6.55 [s]\n", 169 | "Simulation time: 6.60 [s]\n", 170 | "Simulation time: 6.65 [s]\n", 171 | "Simulation time: 6.70 [s]\n", 172 | "Simulation time: 6.75 [s]\n", 173 | "Simulation time: 6.80 [s]\n", 174 | "Simulation time: 6.85 [s]\n", 175 | "Simulation time: 6.90 [s]\n", 176 | "Simulation time: 6.95 [s]\n", 177 | "Simulation time: 7.00 [s]\n", 178 | "Simulation time: 7.05 [s]\n", 179 | "Simulation time: 7.10 [s]\n", 180 | "Simulation time: 7.15 [s]\n", 181 | "Simulation time: 7.20 [s]\n", 182 | "Simulation time: 7.25 [s]\n", 183 | "Simulation time: 7.30 [s]\n", 184 | "Simulation time: 7.35 [s]\n", 185 | "Simulation time: 7.40 [s]\n", 186 | "Simulation time: 7.45 [s]\n", 187 | "Simulation time: 7.50 [s]\n", 188 | "Simulation time: 7.55 [s]\n", 189 | "Simulation time: 7.60 [s]\n", 190 | "Simulation time: 7.65 [s]\n", 191 | "Simulation time: 7.70 [s]\n", 192 | "Simulation time: 7.75 [s]\n", 193 | "Simulation time: 7.80 [s]\n", 194 | "Simulation time: 7.85 [s]\n", 195 | "Simulation time: 7.90 [s]\n", 196 | "Simulation time: 7.95 [s]\n", 197 | "Simulation time: 8.00 [s]\n", 198 | "Simulation time: 8.05 [s]\n", 199 | "Simulation time: 8.10 [s]\n", 200 | "Simulation time: 8.15 [s]\n", 201 | "Simulation time: 8.20 [s]\n", 202 | "Simulation time: 8.25 [s]\n", 203 | "Simulation time: 8.30 [s]\n", 204 | "Simulation time: 8.35 [s]\n", 205 | "Simulation time: 8.40 [s]\n", 206 | "Simulation time: 8.45 [s]\n", 207 | "Simulation time: 8.50 [s]\n", 208 | "Simulation time: 8.55 [s]\n", 209 | "Simulation time: 8.60 [s]\n", 210 | "Simulation time: 8.65 [s]\n", 211 | "Simulation time: 8.70 [s]\n", 212 | "Simulation time: 8.75 [s]\n", 213 | "Simulation time: 8.80 [s]\n", 214 | "Simulation time: 8.85 [s]\n", 215 | "Simulation time: 8.90 [s]\n", 216 | "Simulation time: 8.95 [s]\n", 217 | "Simulation time: 9.00 [s]\n", 218 | "Simulation time: 9.05 [s]\n", 219 | "Simulation time: 9.10 [s]\n", 220 | "Simulation time: 9.15 [s]\n", 221 | "Simulation time: 9.20 [s]\n", 222 | "Simulation time: 9.25 [s]\n", 223 | "Simulation time: 9.30 [s]\n", 224 | "Simulation time: 9.35 [s]\n", 225 | "Simulation time: 9.40 [s]\n", 226 | "Simulation time: 9.45 [s]\n", 227 | "Simulation time: 9.50 [s]\n", 228 | "Simulation time: 9.55 [s]\n", 229 | "Simulation time: 9.60 [s]\n", 230 | "Simulation time: 9.65 [s]\n", 231 | "Simulation time: 9.70 [s]\n", 232 | "Simulation time: 9.75 [s]\n", 233 | "Simulation time: 9.80 [s]\n", 234 | "Simulation time: 9.85 [s]\n", 235 | "Simulation time: 9.90 [s]\n", 236 | "Simulation time: 9.95 [s]\n", 237 | "Simulation time: 10.00 [s]\n", 238 | "Simulation time: 10.05 [s]\n", 239 | "Simulation time: 10.10 [s]\n", 240 | "Simulation time: 10.15 [s]\n", 241 | "Simulation time: 10.20 [s]\n", 242 | "Simulation time: 10.25 [s]\n", 243 | "Simulation time: 10.30 [s]\n", 244 | "Simulation time: 10.35 [s]\n", 245 | "Simulation time: 10.40 [s]\n", 246 | "Simulation time: 10.45 [s]\n", 247 | "Simulation time: 10.50 [s]\n", 248 | "Simulation time: 10.55 [s]\n", 249 | "Simulation time: 10.60 [s]\n", 250 | "Simulation time: 10.65 [s]\n", 251 | "Simulation time: 10.70 [s]\n", 252 | "Simulation time: 10.75 [s]\n", 253 | "Simulation time: 10.80 [s]\n", 254 | "Simulation time: 10.85 [s]\n", 255 | "Simulation time: 10.90 [s]\n", 256 | "Simulation time: 10.95 [s]\n", 257 | "Simulation time: 11.00 [s]\n", 258 | "Simulation time: 11.05 [s]\n", 259 | "Simulation time: 11.10 [s]\n", 260 | "Simulation time: 11.15 [s]\n", 261 | "Simulation time: 11.20 [s]\n", 262 | "Simulation time: 11.25 [s]\n", 263 | "Simulation time: 11.30 [s]\n", 264 | "Simulation time: 11.35 [s]\n", 265 | "Simulation time: 11.40 [s]\n", 266 | "Simulation time: 11.45 [s]\n", 267 | "Simulation time: 11.50 [s]\n", 268 | "Simulation time: 11.55 [s]\n", 269 | "Simulation time: 11.60 [s]\n", 270 | "Simulation time: 11.65 [s]\n", 271 | "Simulation time: 11.70 [s]\n", 272 | "Simulation time: 11.75 [s]\n", 273 | "Simulation time: 11.80 [s]\n", 274 | "Simulation time: 11.85 [s]\n", 275 | "Simulation time: 11.90 [s]\n", 276 | "Simulation time: 11.95 [s]\n", 277 | "Simulation time: 12.00 [s]\n", 278 | "Simulation time: 12.05 [s]\n", 279 | "Simulation time: 12.10 [s]\n", 280 | "Simulation time: 12.15 [s]\n", 281 | "Simulation time: 12.20 [s]\n", 282 | "Simulation time: 12.25 [s]\n", 283 | "Simulation time: 12.30 [s]\n", 284 | "Simulation time: 12.35 [s]\n", 285 | "Simulation time: 12.40 [s]\n", 286 | "Simulation time: 12.45 [s]\n", 287 | "Simulation time: 12.50 [s]\n", 288 | "Simulation time: 12.55 [s]\n", 289 | "Simulation time: 12.60 [s]\n", 290 | "Simulation time: 12.65 [s]\n", 291 | "Simulation time: 12.70 [s]\n", 292 | "Simulation time: 12.75 [s]\n", 293 | "Simulation time: 12.80 [s]\n", 294 | "Simulation time: 12.85 [s]\n", 295 | "Simulation time: 12.90 [s]\n", 296 | "Simulation time: 12.95 [s]\n", 297 | "Simulation time: 13.00 [s]\n", 298 | "Simulation time: 13.05 [s]\n", 299 | "Simulation time: 13.10 [s]\n", 300 | "Simulation time: 13.15 [s]\n", 301 | "Simulation time: 13.20 [s]\n", 302 | "Simulation time: 13.25 [s]\n", 303 | "Simulation time: 13.30 [s]\n", 304 | "Simulation time: 13.35 [s]\n", 305 | "Simulation time: 13.40 [s]\n", 306 | "Simulation time: 13.45 [s]\n", 307 | "Simulation time: 13.50 [s]\n", 308 | "Simulation time: 13.55 [s]\n", 309 | "Simulation time: 13.60 [s]\n", 310 | "Simulation time: 13.65 [s]\n", 311 | "Simulation time: 13.70 [s]\n", 312 | "Simulation time: 13.75 [s]\n", 313 | "Simulation time: 13.80 [s]\n", 314 | "Simulation time: 13.85 [s]\n", 315 | "Simulation time: 13.90 [s]\n", 316 | "Simulation time: 13.95 [s]\n", 317 | "Simulation time: 14.00 [s]\n", 318 | "Simulation time: 14.05 [s]\n", 319 | "Simulation time: 14.10 [s]\n", 320 | "Simulation time: 14.15 [s]\n", 321 | "Simulation time: 14.20 [s]\n", 322 | "Simulation time: 14.25 [s]\n", 323 | "Simulation time: 14.30 [s]\n", 324 | "Simulation time: 14.35 [s]\n", 325 | "Simulation time: 14.40 [s]\n", 326 | "Simulation time: 14.45 [s]\n", 327 | "Simulation time: 14.50 [s]\n", 328 | "Simulation time: 14.55 [s]\n", 329 | "Simulation time: 14.60 [s]\n", 330 | "Simulation time: 14.65 [s]\n", 331 | "Simulation time: 14.70 [s]\n", 332 | "Simulation time: 14.75 [s]\n", 333 | "Simulation time: 14.80 [s]\n", 334 | "Simulation time: 14.85 [s]\n", 335 | "Simulation time: 14.90 [s]\n", 336 | "Simulation time: 14.95 [s]\n", 337 | "Stopping robot...\n", 338 | "CALC Pos: 15.000000000000078 [-1.73472348e-16 -9.90000000e-01] 0.5000000000000037\n", 339 | "SIM Pos: [0.11791714729590971, -0.9889189768956197, 0.0389245711721176]\n", 340 | "SIM Ori: [-4.73147652e-04 1.47803060e-02 1.07183650e+00]\n", 341 | "Program ended\n" 342 | ] 343 | } 344 | ], 345 | "source": [ 346 | "try:\n", 347 | " # Connect to the CoppeliaSim server\n", 348 | " client = RemoteAPIClient()\n", 349 | " sim = client.require(\"sim\")\n", 350 | " sim.setStepping(True)\n", 351 | "\n", 352 | " # Handle para o ROBÔ\n", 353 | " robotname = 'robotino'\n", 354 | " robotHandle = sim.getObject('/' + robotname)\n", 355 | " \n", 356 | " # Handle para as juntas das RODAS\n", 357 | " wheel1 = sim.getObject('/' + robotname + '/wheel0_joint')\n", 358 | " wheel2 = sim.getObject('/' + robotname + '/wheel1_joint')\n", 359 | " wheel3 = sim.getObject('/' + robotname + '/wheel2_joint')\n", 360 | " \n", 361 | " # Dados Robotino\n", 362 | " L = 0.135 # Metros\n", 363 | " r = 0.040 # Metros\n", 364 | " \n", 365 | " # Cinemática Direta\n", 366 | " Mdir = np.array([[-r/np.sqrt(3), 0, r/np.sqrt(3)], [r/3, (-2*r)/3, r/3], [r/(3*L), r/(3*L), r/(3*L)]])\n", 367 | "\n", 368 | " # Configuração inicial (x, y, w)\n", 369 | " q = np.array([0, 0, 0])\n", 370 | " \n", 371 | " # Lembrar de habilitar o 'Real-time mode' \n", 372 | " # Parar a simulação se estiver executando\n", 373 | " initial_sim_state = sim.getSimulationState()\n", 374 | " if initial_sim_state != 0:\n", 375 | " sim.stopSimulation()\n", 376 | " time.sleep(1)\n", 377 | " \n", 378 | " # Inicia a simulação\n", 379 | " sim.startSimulation()\n", 380 | " sim.step()\n", 381 | " \n", 382 | " print(\"Starting robot control loop...\")\n", 383 | " while (sim_time := sim.getSimulationTime()) <= 15:\n", 384 | " print(f\"Simulation time: {sim_time:.2f} [s]\")\n", 385 | " \n", 386 | " dt = sim.getSimulationTimeStep()\n", 387 | " \n", 388 | " # Cinemática Direta\n", 389 | " u = [np.deg2rad(45), np.deg2rad(45), np.deg2rad(45)]\n", 390 | " \n", 391 | " # Velocidade desejada (x, y, w) \n", 392 | " if sim_time <= 5:\n", 393 | " qdot = np.array([.2, 0, np.deg2rad(10)])\n", 394 | " elif sim_time <= 10: \n", 395 | " qdot = np.array([0, -.2, np.deg2rad(-10)])\n", 396 | " else:\n", 397 | " qdot = np.array([-.2, 0, 0])\n", 398 | " \n", 399 | " #qdot = np.array([0, .3, 0])\n", 400 | " \n", 401 | " # Cinemática Inversa\n", 402 | " # w1, w2, w3\n", 403 | " Minv = np.linalg.inv(Rz(q[2]) @ Mdir)\n", 404 | " u = Minv @ qdot\n", 405 | "\n", 406 | " # Enviando velocidades\n", 407 | " sim.setJointTargetVelocity(wheel1, u[0])\n", 408 | " sim.setJointTargetVelocity(wheel2, u[1])\n", 409 | " sim.setJointTargetVelocity(wheel3, u[2]) \n", 410 | " \n", 411 | " # Calculando posição\n", 412 | " q = q + (Rz(q[2]) @ Mdir @ u)*dt\n", 413 | "\n", 414 | " sim.step()\n", 415 | "\n", 416 | " # Parando o robô\n", 417 | " print(\"Stopping robot...\")\n", 418 | " sim.setJointTargetVelocity(wheel1, 0)\n", 419 | " sim.setJointTargetVelocity(wheel2, 0)\n", 420 | " sim.setJointTargetVelocity(wheel3, 0)\n", 421 | " \n", 422 | " print('CALC Pos: ', sim_time, q[:2], np.rad2deg(q[2]))\n", 423 | " \n", 424 | " pos = sim.getObjectPosition(robotHandle, sim.handle_world)\n", 425 | " print('SIM Pos: ', pos)\n", 426 | "\n", 427 | " ori = sim.getObjectOrientation(robotHandle, sim.handle_world)\n", 428 | " print('SIM Ori: ', np.rad2deg(ori))\n", 429 | " \n", 430 | "\n", 431 | "except Exception as e:\n", 432 | " print(f\"An error occurred: {e}\")\n", 433 | " \n", 434 | "# Parando a simulação\n", 435 | "sim.stopSimulation()\n", 436 | "\n", 437 | "print('Program ended')" 438 | ] 439 | }, 440 | { 441 | "cell_type": "markdown", 442 | "metadata": {}, 443 | "source": [ 444 | "# Não-holonômico (Pioneer - diferencial)" 445 | ] 446 | }, 447 | { 448 | "cell_type": "code", 449 | "execution_count": 6, 450 | "metadata": {}, 451 | "outputs": [ 452 | { 453 | "name": "stdout", 454 | "output_type": "stream", 455 | "text": [ 456 | "Starting robot control loop...\n", 457 | "Simulation time: 0.05 [s]\n", 458 | "Simulation time: 0.10 [s]\n", 459 | "Simulation time: 0.20 [s]\n", 460 | "Simulation time: 0.25 [s]\n", 461 | "Simulation time: 0.30 [s]\n", 462 | "Simulation time: 0.40 [s]\n", 463 | "Simulation time: 0.45 [s]\n", 464 | "Simulation time: 0.50 [s]\n", 465 | "Simulation time: 0.55 [s]\n", 466 | "Simulation time: 0.60 [s]\n", 467 | "Simulation time: 0.65 [s]\n", 468 | "Simulation time: 0.70 [s]\n", 469 | "Simulation time: 0.75 [s]\n", 470 | "Simulation time: 0.80 [s]\n", 471 | "Simulation time: 0.85 [s]\n", 472 | "Simulation time: 0.95 [s]\n", 473 | "Simulation time: 1.00 [s]\n", 474 | "Simulation time: 1.05 [s]\n", 475 | "Simulation time: 1.10 [s]\n", 476 | "Simulation time: 1.20 [s]\n", 477 | "Simulation time: 1.25 [s]\n", 478 | "Simulation time: 1.30 [s]\n", 479 | "Simulation time: 1.40 [s]\n", 480 | "Simulation time: 1.45 [s]\n", 481 | "Simulation time: 1.50 [s]\n", 482 | "Simulation time: 1.55 [s]\n", 483 | "Simulation time: 1.60 [s]\n", 484 | "Simulation time: 1.65 [s]\n", 485 | "Simulation time: 1.70 [s]\n", 486 | "Simulation time: 1.75 [s]\n", 487 | "Simulation time: 1.85 [s]\n", 488 | "Simulation time: 1.90 [s]\n", 489 | "Simulation time: 1.95 [s]\n", 490 | "Simulation time: 2.00 [s]\n", 491 | "Simulation time: 2.05 [s]\n", 492 | "Simulation time: 2.10 [s]\n", 493 | "Simulation time: 2.20 [s]\n", 494 | "Simulation time: 2.25 [s]\n", 495 | "Simulation time: 2.30 [s]\n", 496 | "Simulation time: 2.35 [s]\n", 497 | "Simulation time: 2.40 [s]\n", 498 | "Simulation time: 2.50 [s]\n", 499 | "Simulation time: 2.55 [s]\n", 500 | "Simulation time: 2.60 [s]\n", 501 | "Simulation time: 2.65 [s]\n", 502 | "Simulation time: 2.75 [s]\n", 503 | "Simulation time: 2.80 [s]\n", 504 | "Simulation time: 2.85 [s]\n", 505 | "Simulation time: 2.95 [s]\n", 506 | "Simulation time: 3.00 [s]\n", 507 | "Simulation time: 3.05 [s]\n", 508 | "Simulation time: 3.10 [s]\n", 509 | "Simulation time: 3.20 [s]\n", 510 | "Simulation time: 3.25 [s]\n", 511 | "Simulation time: 3.30 [s]\n", 512 | "Simulation time: 3.35 [s]\n", 513 | "Simulation time: 3.45 [s]\n", 514 | "Simulation time: 3.55 [s]\n", 515 | "Simulation time: 3.60 [s]\n", 516 | "Simulation time: 3.65 [s]\n", 517 | "Simulation time: 3.75 [s]\n", 518 | "Simulation time: 3.80 [s]\n", 519 | "Simulation time: 3.85 [s]\n", 520 | "Simulation time: 3.90 [s]\n", 521 | "Simulation time: 3.95 [s]\n", 522 | "Simulation time: 4.00 [s]\n", 523 | "Simulation time: 4.05 [s]\n", 524 | "Simulation time: 4.10 [s]\n", 525 | "Simulation time: 4.20 [s]\n", 526 | "Simulation time: 4.25 [s]\n", 527 | "Simulation time: 4.30 [s]\n", 528 | "Simulation time: 4.35 [s]\n", 529 | "Simulation time: 4.45 [s]\n", 530 | "Simulation time: 4.50 [s]\n", 531 | "Simulation time: 4.55 [s]\n", 532 | "Simulation time: 4.60 [s]\n", 533 | "Simulation time: 4.65 [s]\n", 534 | "Simulation time: 4.70 [s]\n", 535 | "Simulation time: 4.75 [s]\n", 536 | "Simulation time: 4.80 [s]\n", 537 | "Simulation time: 4.85 [s]\n", 538 | "Simulation time: 4.90 [s]\n", 539 | "Simulation time: 4.95 [s]\n", 540 | "Stopping robot...\n", 541 | "CALC Pos: 5.04999999999999 [ 0.76055705 -0.28436063] -41.50000000000005\n", 542 | "SIM Pos: [0.8710421388701828, -0.33903997302197697, 0.13869680937015125]\n", 543 | "SIM Ori: [-4.65661346e-02 -3.66566657e-02 -4.82586538e+01]\n", 544 | "Program ended\n" 545 | ] 546 | } 547 | ], 548 | "source": [ 549 | "try:\n", 550 | " # Connect to the CoppeliaSim server\n", 551 | " client = RemoteAPIClient()\n", 552 | " sim = client.require(\"sim\")\n", 553 | " sim.setStepping(True)\n", 554 | "\n", 555 | " # Handle para o ROBÔ\n", 556 | " robotname = 'Pioneer_p3dx'\n", 557 | " robotHandle = sim.getObject('/' + robotname)\n", 558 | " \n", 559 | " # Handle para as juntas das RODAS\n", 560 | " l_wheel = sim.getObject('/' + robotname + '/'+ robotname + '_leftMotor')\n", 561 | " r_wheel = sim.getObject('/' + robotname + '/'+ robotname + '_rightMotor')\n", 562 | " \n", 563 | " # Dados Pioneer\n", 564 | " # https://www.generationrobots.com/media/Pioneer3DX-P3DX-RevA.pdf\n", 565 | " # L = 0.381 # Metros\n", 566 | " # r = 0.0975 # Metros\n", 567 | " \n", 568 | " L = 0.331\n", 569 | " r = 0.09751\n", 570 | " \n", 571 | " # Lembrar de habilitar o 'Real-time mode' \n", 572 | " # Parar a simulação se estiver executando\n", 573 | " initial_sim_state = sim.getSimulationState()\n", 574 | " if initial_sim_state != 0:\n", 575 | " sim.stopSimulation()\n", 576 | " time.sleep(1)\n", 577 | " \n", 578 | " # Inicia a simulação\n", 579 | " sim.startSimulation()\n", 580 | " sim.step()\n", 581 | " \n", 582 | " # Velocidade desejada (linear, angular)\n", 583 | " v = .2\n", 584 | " w = np.deg2rad(-10)\n", 585 | "\n", 586 | " # Cinemática Inversa\n", 587 | " wr = ((2.0*v) + (w*L))/(2.0*r)\n", 588 | " wl = ((2.0*v) - (w*L))/(2.0*r) \n", 589 | " u = np.array([wr, wl]) \n", 590 | " \n", 591 | " # Enviando velocidades\n", 592 | " sim.setJointTargetVelocity(l_wheel, wl)\n", 593 | " sim.setJointTargetVelocity(r_wheel, wr)\n", 594 | " \n", 595 | " # Configuração inicial (x, y, w)\n", 596 | " q = np.array([0, 0, 0])\n", 597 | " \n", 598 | " print(\"Starting robot control loop...\")\n", 599 | " while (sim_time := sim.getSimulationTime()) <= 5:\n", 600 | " print(f\"Simulation time: {sim_time:.2f} [s]\")\n", 601 | " \n", 602 | " dt = sim.getSimulationTimeStep()\n", 603 | " \n", 604 | " # Cinemática Direta\n", 605 | " Mdir = np.array([[r*np.cos(q[2])/2, r*np.cos(q[2])/2], [r*np.sin(q[2])/2, r*np.sin(q[2])/2], [r/L, -r/L]])\n", 606 | " \n", 607 | " # Calculando posição \n", 608 | " q = q + (Mdir @ u)*dt\n", 609 | "\n", 610 | " sim.step()\n", 611 | "\n", 612 | " # Parando o robô\n", 613 | " print(\"Stopping robot...\")\n", 614 | " sim.setJointTargetVelocity(l_wheel, 0)\n", 615 | " sim.setJointTargetVelocity(r_wheel, 0)\n", 616 | " \n", 617 | " print('CALC Pos: ', sim_time, q[:2], np.rad2deg(q[2]))\n", 618 | " \n", 619 | " pos = sim.getObjectPosition(robotHandle, sim.handle_world)\n", 620 | " print('SIM Pos: ', pos)\n", 621 | "\n", 622 | " ori = sim.getObjectOrientation(robotHandle, sim.handle_world)\n", 623 | " print('SIM Ori: ', np.rad2deg(ori))\n", 624 | " \n", 625 | "\n", 626 | "except Exception as e:\n", 627 | " print(f\"An error occurred: {e}\")\n", 628 | " \n", 629 | "# Parando a simulação\n", 630 | "sim.stopSimulation()\n", 631 | "\n", 632 | "print('Program ended')" 633 | ] 634 | }, 635 | { 636 | "cell_type": "markdown", 637 | "metadata": {}, 638 | "source": [ 639 | "# Para praticar\n", 640 | "\n", 641 | "- Tentar utilizar o modelo do youBot (Kuka) e fazer uma navegação/controle simples\n", 642 | "- Tentar utilizar um modelo do tipo Ackermann (e.g., Manta) e fazer uma navegação/controle simples" 643 | ] 644 | } 645 | ], 646 | "metadata": { 647 | "kernelspec": { 648 | "display_name": "Python 3 (ipykernel)", 649 | "language": "python", 650 | "name": "python3" 651 | }, 652 | "language_info": { 653 | "codemirror_mode": { 654 | "name": "ipython", 655 | "version": 3 656 | }, 657 | "file_extension": ".py", 658 | "mimetype": "text/x-python", 659 | "name": "python", 660 | "nbconvert_exporter": "python", 661 | "pygments_lexer": "ipython3", 662 | "version": "3.11.5" 663 | } 664 | }, 665 | "nbformat": 4, 666 | "nbformat_minor": 4 667 | } 668 | -------------------------------------------------------------------------------- /jupyter-notebooks/aula20-localizacao-markov.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "import matplotlib.pyplot as plt" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "metadata": {}, 16 | "source": [ 17 | "# Exemplo Localização de Markov 1D" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 2, 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "Text(0.5, 1.0, '$bel(x_0)$')" 29 | ] 30 | }, 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | }, 35 | { 36 | "data": { 37 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAp8AAAB6CAYAAAD5/jgQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARqUlEQVR4nO3dfbRldV3H8fcnCUqYGZUHmWRAMTQzc4ihlBLwAR/QpSirsAdNHTPxIcmsRA3NFDBZiA8UttRCNCWipSKwnDRLFHQ54yOKaDgqyDAE5FxAGGD89sfeN8+cuXeGczl373vPvF9rnXU5+/z23t8f9845n/Pb+7d3qgpJkiSpCz/TdwGSJEnaeRg+JUmS1BnDpyRJkjpj+JQkSVJnDJ+SJEnqjOFTkiRJnTF8SpIkqTOGT0mSJHXG8ClJkqTOGD4lSZLUGcOnJA1JskeSLUleNabtLUvykyR/OrT8pCTfTDLW9+Ikq5P8MMnu49yuJI2D4VOStnUIzfvjF8a0vVVAgC9OL0jyC8BfACdV1U/GtJ9pZwO3ttuXpAXF8ClJ21oFbAHWjXl7Xx5Y9grgR8C/jWkf/6+q7gLeDbwiyb3HvX1JuicM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+YmmmtgPrmq/r3XqjSK/YAP0Uxw/B/g88CjJuU9pqq+mOSZwCk076PrgROq6oP9VjZWT6AZlJiYMDbk5cDfAH9H8wXpWuDdwBv7LGrMltH8je5HczWU82kmVd3Za1U98TqfkiRJ6szEnU8hSZKkhcvwKUmSpM4YPiVJktQZw6ckSZI6Y/iUJElSZwyfkiRJ6ozhU5IkSZ0xfEqSJKkzhk9JkiR1xvApSZKkzhg+JUmS1BnDpyRJkjrzf2jK5eDAx7e2AAAAAElFTkSuQmCC\n", 38 | "text/plain": [ 39 | "
" 40 | ] 41 | }, 42 | "metadata": { 43 | "needs_background": "light" 44 | }, 45 | "output_type": "display_data" 46 | } 47 | ], 48 | "source": [ 49 | "N = 10 # Número de células\n", 50 | "x = np.arange(N) # Será usado para a parte de visualização\n", 51 | "\n", 52 | "\n", 53 | "# Criando o vetor para representar os estados\n", 54 | "bel = np.zeros(N)\n", 55 | "\n", 56 | "# Inicializando com distribuição uniforme entre as células 0 e 3\n", 57 | "bel[0:4] = 0.25\n", 58 | "\n", 59 | "fig = plt.figure(figsize=(8,5), dpi=100)\n", 60 | "ax = fig.add_subplot(111, aspect='equal')\n", 61 | "\n", 62 | "ax.bar(x, bel)\n", 63 | "ax.axis([-1, N, 0, 1])\n", 64 | "ax.set_xticks(x)\n", 65 | "ax.set_title('$bel(x_0)$')" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 3, 71 | "metadata": {}, 72 | "outputs": [ 73 | { 74 | "data": { 75 | "text/plain": [ 76 | "Text(0.5, 1.0, '$p(x_1 | u_1, x_0)$')" 77 | ] 78 | }, 79 | "execution_count": 3, 80 | "metadata": {}, 81 | "output_type": "execute_result" 82 | }, 83 | { 84 | "data": { 85 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAp8AAAB6CAYAAAD5/jgQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9y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GZdnp7klcDSqnqwr+LmQ1XdneRa4OC+axmTDcDwF6Gv0XxRmhhJ9gd+Bfj1vmuZB28DzqiqD7avr23HezIwEeGzqv4bOLw9GXV5VW1IchFwQ8+l9cJjPnvUfqiv5YdnL045Eriq+4o0qjT+juYD4ZeqajH8IQmwtO8ixuRTNGeerhx4rAHeB6yctOAJkGQpzRnFG/quZUw+Dwxf3uzRwLd7qGU+vYTmZMbLttVxAfpJ4PtDbQ8ygRmlqu5ug+fDgV8FPtJ3TX1w5rN/ZwEXJllDc1zdy4H9gPN6rWpM2rOIf3qg6cAkK4Hbq+o7/VQ1VufS7Cp6HnBnkqlZ7Duq6t7+yhqPJG8GrgDWAcuAFwBHAM/qsayxqao7gR85PjfJ3cBtk3LcbpIzgUuB79DM8p4CLGdCZpSAs2mOYX098M80x3y+vH1MhPZ6ly8BLqiq7/Vdzzy4FHhDku/Q7HY/BHgNzW7qiZDkV2m+uF9P85n4tva//6nPuvpi+OxZVV2UZFfgVJpruF0HHFVVk/KtfTXw6YHXU8eYXQC8uPNqxm/qElmfGWp/CZNxUsBPARfS/G7eQXMNzGdV1Sd6rUqj2Af4AM0Jjv8D/BvwlEn5G1NVX0jyfOB0mr+jNwAnVdX7+q1srH6FZlJiYsLYkFcBfwm8g+YL0nrgH4C/6LOoMVtB8zu6D83VUD5Ec1LVA71W1ROv8ylJkqTOTNzxFJIkSdpxGT4lSZLUGcOnJEmSOmP4lCRJUmcMn5IkSeqM4VOSJEmdMXxKkiSpM4ZPSZIkdcbwKUmSpM4YPiVJktQZw6ckSZI6Y/iUJElSZ/4f+mo2t2fLEGAAAAAASUVORK5CYII=\n", 86 | "text/plain": [ 87 | "
" 88 | ] 89 | }, 90 | "metadata": { 91 | "needs_background": "light" 92 | }, 93 | "output_type": "display_data" 94 | } 95 | ], 96 | "source": [ 97 | "# Vetor para representar o modelo de transição\n", 98 | "v_trans = np.zeros(N)\n", 99 | "v_trans[2:4] = 0.5\n", 100 | "#v_trans[2:5] = 1/3 # Para verificar o impacto da incerteza\n", 101 | "\n", 102 | "fig = plt.figure(figsize=(8,5), dpi=100)\n", 103 | "ax = fig.add_subplot(111, aspect='equal')\n", 104 | "\n", 105 | "ax.bar(x, v_trans)\n", 106 | "ax.axis([-1, N, 0, 1])\n", 107 | "ax.set_xticks(x)\n", 108 | "ax.set_title('$p(x_1 | u_1, x_0)$')" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 4, 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "data": { 118 | "text/plain": [ 119 | "Text(0.5, 1.0, '$\\\\overline{bel}(x_1)$')" 120 | ] 121 | }, 122 | "execution_count": 4, 123 | "metadata": {}, 124 | "output_type": "execute_result" 125 | }, 126 | { 127 | "data": { 128 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAp8AAAB+CAYAAABib3oGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARlklEQVR4nO3deZBlZXnH8e9PEVScGRdERlkEg4YY4xAGF1RwwwUtRakETdxHibiiUSMuhBhliRTiQsSUG+6EkEIRKFGjEQUtZxAVRVQclWUYAsQZRBhhfPLHOR3v3OmeoXtun9N95/upOnX7vvc95zxvdfe9z33P+74nVYUkSZLUhTv0HYAkSZK2HiafkiRJ6ozJpyRJkjpj8ilJkqTOmHxKkiSpMyafkiRJ6ozJpyRJkjpj8ilJkqTOmHxKkiSpMyafkiRJ6ozJpyRJkjpj8ilJkqTObNN3AJI0VySprs5VVenqXJI0l6Sqs/daSZIkbeW87C5JkqTOmHxK0pAkd0uyPskbRnS8RUn+kOR1Q+VHJflxkpG+FydZluSqJNuP8riSNAomn5K0sX1o3h+/M6LjLQUCfHeiIMl9gTcBR1XVH0Z0ngmnAje1x5ekOcXkU5I2thRYD6wY8fG+N1D2WuA3wH+O6Bz/r6puAz4EvDbJX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xRVZ/uN7KReiJNp8TYJGNDXg38M/CvNF+QrgY+BLyjz6BGbBHN3+jONKuhnEEzqerWXqPqiet8SpIkqTNjN55CkiRJc5fJpyRJkjpj8ilJkqTOmHxKkiSpMyafkiRJ6ozJpyRJkjpj8ilJkqTOmHxKkiSpMyafkiRJ6ozJpyRJkjpj8ilJkqTOmHxKkiSpM/8HiVr2I1xBl/AAAAAASUVORK5CYII=\n", 129 | "text/plain": [ 130 | "
" 131 | ] 132 | }, 133 | "metadata": { 134 | "needs_background": "light" 135 | }, 136 | "output_type": "display_data" 137 | } 138 | ], 139 | "source": [ 140 | "# Nova estimativa é obtida por uma convolução\n", 141 | "bel_pred = np.convolve(bel, v_trans)[:N] # Só preciso pegar o tamanho de bel\n", 142 | "\n", 143 | "fig = plt.figure(figsize=(8,5), dpi=100)\n", 144 | "ax = fig.add_subplot(111, aspect='equal')\n", 145 | "\n", 146 | "ax.bar(x, bel_pred)\n", 147 | "ax.axis([-1, N, 0, 1])\n", 148 | "ax.set_xticks(x)\n", 149 | "ax.set_title('$\\\\overline{bel}(x_1)$')" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 5, 155 | "metadata": {}, 156 | "outputs": [ 157 | { 158 | "data": { 159 | "text/plain": [ 160 | "Text(0.5, 1.0, '$p(z_1 | x_1, M)$')" 161 | ] 162 | }, 163 | "execution_count": 5, 164 | "metadata": {}, 165 | "output_type": "execute_result" 166 | }, 167 | { 168 | "data": { 169 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAp8AAAB6CAYAAAD5/jgQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAA9hAAAPYQGoP6dpAAASaUlEQVR4nO3df7QdZX3v8fdHUmKrSRQoBZH4o0XLba2BgIK9At4Wa9GlWHqLt0usQKVCbaVUWxGK2KqgUki9ammX0oL1B3XZi0VhiVp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Wvf8UxSVf0A+Hq7uqadmPNy4Hf6i2piVtL8va1tOq6BptfliCQvAxZX1b19BTcfqup7Sb4IHNB3LBOyARj+IvRlmi9KUyPJY4BfBn6t71jmwZuB86vqfe36F9v2nglMRfJZVd8Ajmwnoy6tqg1JLgfW9RxaLxzz2aP2Q30t981enHE0cG33EWlUabyV5gPhf1XVrvBGEmBx30FMyMdpZp6uGFjWAO8GVkxb4gmQZDHNjOINfccyIZ8Bhm9v9gTgWz3EMp9OpJnM+OHtVVyAfgL40VDZvUxhjlJV32sTz0cCvwJ8sO+Y+mDPZ/8uBN6VZA3NuLpTgOXAxb1GNSHtLOKfGSh6XJIVwJ1VdXM/UU3U22guFT0P2JJkphd7U1Xd1V9Yk5HkDcDVwC3AEuAFwFHAs3oMa2Kqagtwv/G5Sb4H3DEt43aTXABcCdxM08t7NrCUKelRAi6iGcP6auDvacZ8ntIuU6G93+WJwKVV9cO+45kHVwJnJbmZ5rL7QcAZNJepp0KSX6H54n4jzWfim9t//02fcfXF5LNnVXV5kj2Bc2ju4XYDcExVTcu39kOATwysz4wxuxR4cefRTN7MLbI+OVR+ItMxKeCngHfR/G5uorkH5rOq6qO9RqVRPBp4L80Ex/8APgscNi3vMVX1uSTPB86jeR9dB5xeVe/uN7KJ+mWaTompScaG/B7wZ8Dbab4grQf+CvjTPoOasGU0v6OPprkbygdoJlXd02tUPfE+n5IkSerM1I2nkCRJ0s7L5FOSJEmdMfmUJElSZ0w+JUmS1BmTT0mSJHXG5FOSJEmdMfmUJElSZ0w+JUmS1BmTT0mSJHXG5FOSJEmdMfmUJElSZ0w+JUmS1Jn/D4ZAQwRT1togAAAAAElFTkSuQmCC\n", 170 | "text/plain": [ 171 | "
" 172 | ] 173 | }, 174 | "metadata": { 175 | "needs_background": "light" 176 | }, 177 | "output_type": "display_data" 178 | } 179 | ], 180 | "source": [ 181 | "# Vetor para representar o modelo de observação\n", 182 | "v_obs = np.zeros(N)\n", 183 | "v_obs[5:7] = 0.5\n", 184 | "\n", 185 | "fig = plt.figure(figsize=(8,5), dpi=100)\n", 186 | "ax = fig.add_subplot(111, aspect='equal')\n", 187 | "\n", 188 | "ax.bar(x, v_obs)\n", 189 | "ax.axis([-1, N, 0, 1])\n", 190 | "ax.set_xticks(x)\n", 191 | "ax.set_title('$p(z_1 | x_1, M)$')" 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": 6, 197 | "metadata": {}, 198 | "outputs": [ 199 | { 200 | "data": { 201 | "text/plain": [ 202 | "Text(0.5, 1.0, '$bel(x_1)$ - Normalizado')" 203 | ] 204 | }, 205 | "execution_count": 6, 206 | "metadata": {}, 207 | "output_type": "execute_result" 208 | }, 209 | { 210 | "data": { 211 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAp8AAAB6CAYAAAD5/jgQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARW0lEQVR4nO3de7QdZXnH8e9PEVRMIopI1IBi0aq1hhK8oAJe8IIuRVkt2ipV4w28oVUripRaFawsRAXF1hveqaULRWCJWq0o6DLBG4qoELlICAI1QYQI4ekfM6fs7JyTcE72mcnZfD9rzdpn3v3OzPOuc86eZ7/zvjOpKiRJkqQu3KHvACRJknT7YfIpSZKkzph8SpIkqTMmn5IkSeqMyackSZI6Y/IpSZKkzph8SpIkqTMmn5IkSeqMyackSZI6Y/IpSZKkzph8StKQJHdLsi7JG0e0vwVJbkny+qHyI5L8PMlIP4uTLE3y2yTbjnK/kjQKJp+StKHdaT4fvz+i/S0BAvxgoiDJfYA3A0dU1S0jOs6Ek4Dr2/1L0hbF5FOSNrQEWAcsH/H+fjhQ9jrg98B/jegY/6+qbgY+ArwuyV1HvX9J2hwmn5K0oT2A84E9k5yd5Pokv07yquGKSR6X5Kwkq5P8b5LTk+w6yf4uqKrr2222BpYCnxvs9UyyMMkfknxh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kdcbkU5IkSZ0x+ZQkSVJnTD4lSZLUGZNPSZIkdcbkU5IkSZ0x+ZQkSVJnTD4lSZLUGZNPSZIkdcbkU5IkSZ35Pw4TylaMdO/dAAAAAElFTkSuQmCC\n", 212 | "text/plain": [ 213 | "
" 214 | ] 215 | }, 216 | "metadata": { 217 | "needs_background": "light" 218 | }, 219 | "output_type": "display_data" 220 | }, 221 | { 222 | "data": { 223 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAp8AAAB6CAYAAAD5/jgQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVCUlEQVR4nO3de7wVZb3H8c83EbwBqaSggpcyj6csCCi1ErMsU095eZVa1kEpE600T14zo/JahlZado5aapZm9KKDSKGmZYEeQU0tNVNUlIt5CQjlIv7OH88sXY5rr73XYu2ZvZbf9+s1r+0888w8v2f2lvVbz8wzo4jAzMzMzKwIrys7ADMzMzN77XDyaWZmZmaFcfJpZmZmZoVx8mlmZmZmhXHyaWZmZmaFcfJpZmZmZoVx8mlmZmZmhXHyaWZmZmaFcfJpZmZmZoVx8mlmZmZmhXHyaWZ1SdpI0hpJX27R8QZLelHSl3Llp0n6q6SW/rskaYKkJyRt2MrjZsceLykkrZC0dY3tN0u6t9XtFqWqf9vUKysgjkmS/C5osw7h5NPMujOa9G/FbS063hhAwO2VAklbACcAp0XEiy1qp+IyYHl2/N4yADi9F4/fl0wHdgEWlh2ImbUnJ59m1p0xwBpgbouPd2dV2THAP4FftaiNl0TEC8CPgGMkbdDq42d+A3xC0tt76fgA9GL8PRYR/4iIWyNiZdmxmFl7cvJpZt0ZC9wL7CrpFknLJf1d0tH5ipLeI2mmpCWSnpU0XdL2NY53X0Qsz/bpD0wAflY96ilpmKR/Sboq18a+klZLOqOBPlwJDAIObmCfRnwLeBo4pyeVs/N0o6Rlkp6TNEvSP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rjJNPMzMzMyuMk08zMzMzK4yTTzMzMzMrjJNPMzMzMyuMk08zMzMzK8z/AyPNFNyCA/wMAAAAAElFTkSuQmCC\n", 224 | "text/plain": [ 225 | "
" 226 | ] 227 | }, 228 | "metadata": { 229 | "needs_background": "light" 230 | }, 231 | "output_type": "display_data" 232 | } 233 | ], 234 | "source": [ 235 | "# Correção da predição\n", 236 | "bel = v_obs * bel_pred\n", 237 | "\n", 238 | "fig = plt.figure(figsize=(8,5), dpi=100)\n", 239 | "ax = fig.add_subplot(111, aspect='equal')\n", 240 | "\n", 241 | "ax.bar(x, bel)\n", 242 | "ax.axis([-1, N, 0, 1])\n", 243 | "ax.set_xticks(x)\n", 244 | "ax.set_title('$bel(x_1)$')\n", 245 | "\n", 246 | "\n", 247 | "# Normalizando bel\n", 248 | "n = 1/np.sum(bel)\n", 249 | "bel = n * bel\n", 250 | "\n", 251 | "fig = plt.figure(figsize=(8,5), dpi=100)\n", 252 | "ax = fig.add_subplot(111, aspect='equal')\n", 253 | "\n", 254 | "ax.bar(x, bel)\n", 255 | "ax.axis([-1, N, 0, 1])\n", 256 | "ax.set_xticks(x)\n", 257 | "ax.set_title('$bel(x_1)$ - Normalizado')" 258 | ] 259 | }, 260 | { 261 | "cell_type": "markdown", 262 | "metadata": {}, 263 | "source": [ 264 | "# Para praticar\n", 265 | "\n", 266 | "- Fazer a localização considerando robôs com 2 e 3 DoF.\n", 267 | "- Considerar modelos mais completos de ação e observação." 268 | ] 269 | } 270 | ], 271 | "metadata": { 272 | "kernelspec": { 273 | "display_name": "Python 3", 274 | "language": "python", 275 | "name": "python3" 276 | }, 277 | "language_info": { 278 | "codemirror_mode": { 279 | "name": "ipython", 280 | "version": 3 281 | }, 282 | "file_extension": ".py", 283 | "mimetype": "text/x-python", 284 | "name": "python", 285 | "nbconvert_exporter": "python", 286 | "pygments_lexer": "ipython3", 287 | "version": "3.8.5" 288 | } 289 | }, 290 | "nbformat": 4, 291 | "nbformat_minor": 4 292 | } 293 | -------------------------------------------------------------------------------- /jupyter-notebooks/simConst.py: -------------------------------------------------------------------------------- 1 | #constants 2 | #Scene object types. Values are serialized 3 | sim_object_shape_type =0 4 | sim_object_joint_type =1 5 | sim_object_graph_type =2 6 | sim_object_camera_type =3 7 | sim_object_dummy_type =4 8 | sim_object_proximitysensor_type =5 9 | sim_object_reserved1 =6 10 | sim_object_reserved2 =7 11 | sim_object_path_type =8 12 | sim_object_visionsensor_type =9 13 | sim_object_volume_type =10 14 | sim_object_mill_type =11 15 | sim_object_forcesensor_type =12 16 | sim_object_light_type =13 17 | sim_object_mirror_type =14 18 | 19 | #General object types. Values are serialized 20 | sim_appobj_object_type =109 21 | sim_appobj_collision_type =110 22 | sim_appobj_distance_type =111 23 | sim_appobj_simulation_type =112 24 | sim_appobj_ik_type =113 25 | sim_appobj_constraintsolver_type=114 26 | sim_appobj_collection_type =115 27 | sim_appobj_ui_type =116 28 | sim_appobj_script_type =117 29 | sim_appobj_pathplanning_type =118 30 | sim_appobj_RESERVED_type =119 31 | sim_appobj_texture_type =120 32 | 33 | # Ik calculation methods. Values are serialized 34 | sim_ik_pseudo_inverse_method =0 35 | sim_ik_damped_least_squares_method =1 36 | sim_ik_jacobian_transpose_method =2 37 | 38 | # Ik constraints. Values are serialized 39 | sim_ik_x_constraint =1 40 | sim_ik_y_constraint =2 41 | sim_ik_z_constraint =4 42 | sim_ik_alpha_beta_constraint=8 43 | sim_ik_gamma_constraint =16 44 | sim_ik_avoidance_constraint =64 45 | 46 | # Ik calculation results 47 | sim_ikresult_not_performed =0 48 | sim_ikresult_success =1 49 | sim_ikresult_fail =2 50 | 51 | # Scene object sub-types. Values are serialized 52 | # Light sub-types 53 | sim_light_omnidirectional_subtype =1 54 | sim_light_spot_subtype =2 55 | sim_light_directional_subtype =3 56 | # Joint sub-types 57 | sim_joint_revolute_subtype =10 58 | sim_joint_prismatic_subtype =11 59 | sim_joint_spherical_subtype =12 60 | # Shape sub-types 61 | sim_shape_simpleshape_subtype =20 62 | sim_shape_multishape_subtype =21 63 | # Proximity sensor sub-types 64 | sim_proximitysensor_pyramid_subtype =30 65 | sim_proximitysensor_cylinder_subtype=31 66 | sim_proximitysensor_disc_subtype =32 67 | sim_proximitysensor_cone_subtype =33 68 | sim_proximitysensor_ray_subtype =34 69 | # Mill sub-types 70 | sim_mill_pyramid_subtype =40 71 | sim_mill_cylinder_subtype =41 72 | sim_mill_disc_subtype =42 73 | sim_mill_cone_subtype =42 74 | # No sub-type 75 | sim_object_no_subtype =200 76 | 77 | 78 | #Scene object main properties (serialized) 79 | sim_objectspecialproperty_collidable =0x0001 80 | sim_objectspecialproperty_measurable =0x0002 81 | #reserved =0x0004 82 | #reserved =0x0008 83 | sim_objectspecialproperty_detectable_ultrasonic =0x0010 84 | sim_objectspecialproperty_detectable_infrared =0x0020 85 | sim_objectspecialproperty_detectable_laser =0x0040 86 | sim_objectspecialproperty_detectable_inductive =0x0080 87 | sim_objectspecialproperty_detectable_capacitive =0x0100 88 | sim_objectspecialproperty_renderable =0x0200 89 | sim_objectspecialproperty_detectable_all =sim_objectspecialproperty_detectable_ultrasonic|sim_objectspecialproperty_detectable_infrared|sim_objectspecialproperty_detectable_laser|sim_objectspecialproperty_detectable_inductive|sim_objectspecialproperty_detectable_capacitive 90 | sim_objectspecialproperty_cuttable =0x0400 91 | sim_objectspecialproperty_pathplanning_ignored =0x0800 92 | 93 | # Model properties (serialized) 94 | sim_modelproperty_not_collidable =0x0001 95 | sim_modelproperty_not_measurable =0x0002 96 | sim_modelproperty_not_renderable =0x0004 97 | sim_modelproperty_not_detectable =0x0008 98 | sim_modelproperty_not_cuttable =0x0010 99 | sim_modelproperty_not_dynamic =0x0020 100 | sim_modelproperty_not_respondable =0x0040 # cannot be selected if sim_modelproperty_not_dynamic is not selected 101 | sim_modelproperty_not_reset =0x0080 # Model is not reset at simulation end. This flag is cleared at simulation end 102 | sim_modelproperty_not_visible =0x0100 # Whole model is invisible independent of local visibility settings 103 | sim_modelproperty_not_model =0xf000 # object is not a model 104 | 105 | 106 | # Check the documentation instead of comments below!! 107 | # Following messages are dispatched to the Lua-message container 108 | sim_message_ui_button_state_change =0 # a UI button slider etc. changed (due to a user's action). aux[0]=UI handle aux[1]=button handle aux[2]=button attributes aux[3]=slider position (if slider) 109 | sim_message_reserved9 =1 # Do not use 110 | sim_message_object_selection_changed=2 111 | sim_message_reserved10 =3 # do not use 112 | sim_message_model_loaded =4 113 | sim_message_reserved11 =5 # do not use 114 | sim_message_keypress =6 # a key was pressed while the focus was on a page (aux[0]=key aux[1]=ctrl and shift key state) 115 | sim_message_bannerclicked =7 # a banner was clicked (aux[0]=banner ID) 116 | 117 | 118 | # Following messages are dispatched only to the C-API (not available from Lua) 119 | sim_message_for_c_api_only_start =0x100 # Do not use 120 | sim_message_reserved1 =0x101 # Do not use 121 | sim_message_reserved2 =0x102 # Do not use 122 | sim_message_reserved3 =0x103 # Do not use 123 | sim_message_eventcallback_scenesave =0x104 # about to save a scene 124 | sim_message_eventcallback_modelsave =0x105 # about to save a model (current selection will be saved) 125 | sim_message_eventcallback_moduleopen =0x106 # called when simOpenModule in Lua is called 126 | sim_message_eventcallback_modulehandle =0x107 # called when simHandleModule in Lua is called with argument false 127 | sim_message_eventcallback_moduleclose =0x108 # called when simCloseModule in Lua is called 128 | sim_message_reserved4 =0x109 # Do not use 129 | sim_message_reserved5 =0x10a # Do not use 130 | sim_message_reserved6 =0x10b # Do not use 131 | sim_message_reserved7 =0x10c # Do not use 132 | sim_message_eventcallback_instancepass =0x10d # Called once every main application loop pass. auxiliaryData[0] contains event flags of events that happened since last time 133 | sim_message_eventcallback_broadcast =0x10e 134 | sim_message_eventcallback_imagefilter_enumreset =0x10f 135 | sim_message_eventcallback_imagefilter_enumerate =0x110 136 | sim_message_eventcallback_imagefilter_adjustparams =0x111 137 | sim_message_eventcallback_imagefilter_reserved =0x112 138 | sim_message_eventcallback_imagefilter_process =0x113 139 | sim_message_eventcallback_reserved1 =0x114 # do not use 140 | sim_message_eventcallback_reserved2 =0x115 # do not use 141 | sim_message_eventcallback_reserved3 =0x116 # do not use 142 | sim_message_eventcallback_reserved4 =0x117 # do not use 143 | sim_message_eventcallback_abouttoundo =0x118 # the undo button was hit and a previous state is about to be restored 144 | sim_message_eventcallback_undoperformed =0x119 # the undo button was hit and a previous state restored 145 | sim_message_eventcallback_abouttoredo =0x11a # the redo button was hit and a future state is about to be restored 146 | sim_message_eventcallback_redoperformed =0x11b # the redo button was hit and a future state restored 147 | sim_message_eventcallback_scripticondblclick =0x11c # scipt icon was double clicked. (aux[0]=object handle associated with script set replyData[0] to 1 if script should not be opened) 148 | sim_message_eventcallback_simulationabouttostart =0x11d 149 | sim_message_eventcallback_simulationended =0x11e 150 | sim_message_eventcallback_reserved5 =0x11f # do not use 151 | sim_message_eventcallback_keypress =0x120 # a key was pressed while the focus was on a page (aux[0]=key aux[1]=ctrl and shift key state) 152 | sim_message_eventcallback_modulehandleinsensingpart =0x121 # called when simHandleModule in Lua is called with argument true 153 | sim_message_eventcallback_renderingpass =0x122 # called just before the scene is rendered 154 | sim_message_eventcallback_bannerclicked =0x123 # called when a banner was clicked (aux[0]=banner ID) 155 | sim_message_eventcallback_menuitemselected =0x124 # auxiliaryData[0] indicates the handle of the item auxiliaryData[1] indicates the state of the item 156 | sim_message_eventcallback_refreshdialogs =0x125 # aux[0]=refresh degree (0=light 1=medium 2=full) 157 | sim_message_eventcallback_sceneloaded =0x126 158 | sim_message_eventcallback_modelloaded =0x127 159 | sim_message_eventcallback_instanceswitch =0x128 160 | sim_message_eventcallback_guipass =0x129 161 | sim_message_eventcallback_mainscriptabouttobecalled =0x12a 162 | sim_message_eventcallback_rmlposition =0x12b #the command simRMLPosition was called. The appropriate plugin should handle the call 163 | sim_message_eventcallback_rmlvelocity =0x12c # the command simRMLVelocity was called. The appropriate plugin should handle the call 164 | sim_message_simulation_start_resume_request =0x1000 165 | sim_message_simulation_pause_request =0x1001 166 | sim_message_simulation_stop_request =0x1002 167 | 168 | # Scene object properties. Combine with the | operator 169 | sim_objectproperty_reserved1 =0x0000 170 | sim_objectproperty_reserved2 =0x0001 171 | sim_objectproperty_reserved3 =0x0002 172 | sim_objectproperty_reserved4 =0x0003 173 | sim_objectproperty_reserved5 =0x0004 # formely sim_objectproperty_visible 174 | sim_objectproperty_reserved6 =0x0008 # formely sim_objectproperty_wireframe 175 | sim_objectproperty_collapsed =0x0010 176 | sim_objectproperty_selectable =0x0020 177 | sim_objectproperty_reserved7 =0x0040 178 | sim_objectproperty_selectmodelbaseinstead =0x0080 179 | sim_objectproperty_dontshowasinsidemodel =0x0100 180 | # reserved =0x0200 181 | sim_objectproperty_canupdatedna =0x0400 182 | sim_objectproperty_selectinvisible =0x0800 183 | sim_objectproperty_depthinvisible =0x1000 184 | 185 | 186 | # type of arguments (input and output) for custom lua commands 187 | sim_lua_arg_nil =0 188 | sim_lua_arg_bool =1 189 | sim_lua_arg_int =2 190 | sim_lua_arg_float =3 191 | sim_lua_arg_string =4 192 | sim_lua_arg_invalid =5 193 | sim_lua_arg_table =8 194 | 195 | # custom user interface properties. Values are serialized. 196 | sim_ui_property_visible =0x0001 197 | sim_ui_property_visibleduringsimulationonly =0x0002 198 | sim_ui_property_moveable =0x0004 199 | sim_ui_property_relativetoleftborder =0x0008 200 | sim_ui_property_relativetotopborder =0x0010 201 | sim_ui_property_fixedwidthfont =0x0020 202 | sim_ui_property_systemblock =0x0040 203 | sim_ui_property_settocenter =0x0080 204 | sim_ui_property_rolledup =0x0100 205 | sim_ui_property_selectassociatedobject =0x0200 206 | sim_ui_property_visiblewhenobjectselected =0x0400 207 | 208 | 209 | # button properties. Values are serialized. 210 | sim_buttonproperty_button =0x0000 211 | sim_buttonproperty_label =0x0001 212 | sim_buttonproperty_slider =0x0002 213 | sim_buttonproperty_editbox =0x0003 214 | sim_buttonproperty_staydown =0x0008 215 | sim_buttonproperty_enabled =0x0010 216 | sim_buttonproperty_borderless =0x0020 217 | sim_buttonproperty_horizontallycentered =0x0040 218 | sim_buttonproperty_ignoremouse =0x0080 219 | sim_buttonproperty_isdown =0x0100 220 | sim_buttonproperty_transparent =0x0200 221 | sim_buttonproperty_nobackgroundcolor =0x0400 222 | sim_buttonproperty_rollupaction =0x0800 223 | sim_buttonproperty_closeaction =0x1000 224 | sim_buttonproperty_verticallycentered =0x2000 225 | sim_buttonproperty_downupevent =0x4000 226 | 227 | 228 | # Simulation status 229 | sim_simulation_stopped =0x00 # Simulation is stopped 230 | sim_simulation_paused =0x08 # Simulation is paused 231 | sim_simulation_advancing =0x10 # Simulation is advancing 232 | sim_simulation_advancing_firstafterstop =sim_simulation_advancing|0x00 # First simulation pass (1x) 233 | sim_simulation_advancing_running =sim_simulation_advancing|0x01 # Normal simulation pass (>=1x) 234 | # reserved =sim_simulation_advancing|0x02 235 | sim_simulation_advancing_lastbeforepause =sim_simulation_advancing|0x03 # Last simulation pass before pause (1x) 236 | sim_simulation_advancing_firstafterpause =sim_simulation_advancing|0x04 # First simulation pass after pause (1x) 237 | sim_simulation_advancing_abouttostop =sim_simulation_advancing|0x05 # "Trying to stop" simulation pass (>=1x) 238 | sim_simulation_advancing_lastbeforestop =sim_simulation_advancing|0x06 # Last simulation pass (1x) 239 | 240 | 241 | # Script execution result (first return value) 242 | sim_script_no_error =0 243 | sim_script_main_script_nonexistent =1 244 | sim_script_main_script_not_called =2 245 | sim_script_reentrance_error =4 246 | sim_script_lua_error =8 247 | sim_script_call_error =16 248 | 249 | 250 | # Script types (serialized!) 251 | sim_scripttype_mainscript =0 252 | sim_scripttype_childscript =1 253 | sim_scripttype_jointctrlcallback =4 254 | sim_scripttype_contactcallback =5 255 | sim_scripttype_customizationscript =6 256 | sim_scripttype_generalcallback =7 257 | 258 | # API call error messages 259 | sim_api_errormessage_ignore =0 # does not memorize nor output errors 260 | sim_api_errormessage_report =1 # memorizes errors (default for C-API calls) 261 | sim_api_errormessage_output =2 # memorizes and outputs errors (default for Lua-API calls) 262 | 263 | 264 | # special argument of some functions 265 | sim_handle_all =-2 266 | sim_handle_all_except_explicit =-3 267 | sim_handle_self =-4 268 | sim_handle_main_script =-5 269 | sim_handle_tree =-6 270 | sim_handle_chain =-7 271 | sim_handle_single =-8 272 | sim_handle_default =-9 273 | sim_handle_all_except_self =-10 274 | sim_handle_parent =-11 275 | 276 | 277 | # special handle flags 278 | sim_handleflag_assembly =0x400000 279 | sim_handleflag_model =0x800000 280 | 281 | 282 | # distance calculation methods (serialized) 283 | sim_distcalcmethod_dl =0 284 | sim_distcalcmethod_dac =1 285 | sim_distcalcmethod_max_dl_dac =2 286 | sim_distcalcmethod_dl_and_dac =3 287 | sim_distcalcmethod_sqrt_dl2_and_dac2=4 288 | sim_distcalcmethod_dl_if_nonzero =5 289 | sim_distcalcmethod_dac_if_nonzero =6 290 | 291 | 292 | # Generic dialog styles 293 | sim_dlgstyle_message =0 294 | sim_dlgstyle_input =1 295 | sim_dlgstyle_ok =2 296 | sim_dlgstyle_ok_cancel =3 297 | sim_dlgstyle_yes_no =4 298 | sim_dlgstyle_dont_center =32# can be combined with one of above values. Only with this flag can the position of the related UI be set just after dialog creation 299 | 300 | # Generic dialog return values 301 | sim_dlgret_still_open =0 302 | sim_dlgret_ok =1 303 | sim_dlgret_cancel =2 304 | sim_dlgret_yes =3 305 | sim_dlgret_no =4 306 | 307 | 308 | # Path properties 309 | sim_pathproperty_show_line =0x0001 310 | sim_pathproperty_show_orientation =0x0002 311 | sim_pathproperty_closed_path =0x0004 312 | sim_pathproperty_automatic_orientation =0x0008 313 | sim_pathproperty_invert_velocity =0x0010 314 | sim_pathproperty_infinite_acceleration =0x0020 315 | sim_pathproperty_flat_path =0x0040 316 | sim_pathproperty_show_position =0x0080 317 | sim_pathproperty_auto_velocity_profile_translation =0x0100 318 | sim_pathproperty_auto_velocity_profile_rotation =0x0200 319 | sim_pathproperty_endpoints_at_zero =0x0400 320 | sim_pathproperty_keep_x_up =0x0800 321 | 322 | 323 | # drawing objects 324 | # following are mutually exclusive 325 | sim_drawing_points =0 # 3 values per point (point size in pixels) 326 | sim_drawing_lines =1 # 6 values per line (line size in pixels) 327 | sim_drawing_triangles =2 # 9 values per triangle 328 | sim_drawing_trianglepoints =3 # 6 values per point (3 for triangle position 3 for triangle normal vector) (triangle size in meters) 329 | sim_drawing_quadpoints =4 # 6 values per point (3 for quad position 3 for quad normal vector) (quad size in meters) 330 | sim_drawing_discpoints =5 # 6 values per point (3 for disc position 3 for disc normal vector) (disc size in meters) 331 | sim_drawing_cubepoints =6 # 6 values per point (3 for cube position 3 for cube normal vector) (cube size in meters) 332 | sim_drawing_spherepoints =7 # 3 values per point (sphere size in meters) 333 | 334 | # following can be or-combined 335 | sim_drawing_itemcolors =0x00020 # +3 values per item (each item has its own ambient color (rgb values)). 336 | # Mutually exclusive with sim_drawing_vertexcolors 337 | sim_drawing_vertexcolors =0x00040 # +3 values per vertex (each vertex has its own ambient color (rgb values). Only for sim_drawing_lines (+6) and for sim_drawing_triangles(+9)). Mutually exclusive with sim_drawing_itemcolors 338 | sim_drawing_itemsizes =0x00080 # +1 value per item (each item has its own size). Not for sim_drawing_triangles 339 | sim_drawing_backfaceculling =0x00100 # back faces are not displayed for all items 340 | sim_drawing_wireframe =0x00200 # all items displayed in wireframe 341 | sim_drawing_painttag =0x00400 # all items are tagged as paint (for additinal processing at a later stage) 342 | sim_drawing_followparentvisibility =0x00800 # if the object is associated with a scene object then it follows that visibility otherwise it is always visible 343 | sim_drawing_cyclic =0x01000 # if the max item count was reached then the first items are overwritten. 344 | sim_drawing_50percenttransparency =0x02000 # the drawing object will be 50% transparent 345 | sim_drawing_25percenttransparency =0x04000 # the drawing object will be 25% transparent 346 | sim_drawing_12percenttransparency =0x08000 # the drawing object will be 12.5% transparent 347 | sim_drawing_emissioncolor =0x10000 # When used in combination with sim_drawing_itemcolors or sim_drawing_vertexcolors then the specified colors will be for the emissive component 348 | sim_drawing_facingcamera =0x20000 # Only for trianglepoints quadpoints discpoints and cubepoints. If specified the normal verctor is calculated to face the camera (each item data requires 3 values less) 349 | sim_drawing_overlay =0x40000 # When specified objects are always drawn on top of "regular objects" 350 | sim_drawing_itemtransparency =0x80000 # +1 value per item (each item has its own transparency value (0-1)). Not compatible with sim_drawing_vertexcolors 351 | 352 | # banner values 353 | # following can be or-combined 354 | sim_banner_left =0x00001 # Banners display on the left of the specified point 355 | sim_banner_right =0x00002 # Banners display on the right of the specified point 356 | sim_banner_nobackground =0x00004 # Banners have no background rectangle 357 | sim_banner_overlay =0x00008 # When specified banners are always drawn on top of "regular objects" 358 | sim_banner_followparentvisibility =0x00010 # if the object is associated with a scene object then it follows that visibility otherwise it is always visible 359 | sim_banner_clickselectsparent =0x00020 # if the object is associated with a scene object then clicking the banner will select the scene object 360 | sim_banner_clicktriggersevent =0x00040 # if the banner is clicked an event is triggered (sim_message_eventcallback_bannerclicked and sim_message_bannerclicked are generated) 361 | sim_banner_facingcamera =0x00080 # If specified the banner will always face the camera by rotating around the banner's vertical axis (y-axis) 362 | sim_banner_fullyfacingcamera =0x00100 # If specified the banner will always fully face the camera (the banner's orientation is same as the camera looking at it) 363 | sim_banner_backfaceculling =0x00200 # If specified the banner will only be visible from one side 364 | sim_banner_keepsamesize =0x00400 # If specified the banner will always appear in the same size. In that case size represents the character height in pixels 365 | sim_banner_bitmapfont =0x00800 # If specified a fixed-size bitmap font is used. The text will also always fully face the camera and be right 366 | # to the specified position. Bitmap fonts are not clickable 367 | 368 | 369 | # particle objects following are mutually exclusive 370 | sim_particle_points1 =0 # 6 values per point (pt1 and pt2. Pt1 is start position pt2-pt1 is the initial velocity vector). i 371 | #Point is 1 pixel big. Only appearance is a point internally handled as a perfect sphere 372 | sim_particle_points2 =1 # 6 values per point. Point is 2 pixel big. Only appearance is a point internally handled as a perfect sphere 373 | sim_particle_points4 =2 # 6 values per point. Point is 4 pixel big. Only appearance is a point internally handled as a perfect sphere 374 | sim_particle_roughspheres =3 # 6 values per sphere. Only appearance is rough. Internally a perfect sphere 375 | sim_particle_spheres =4 # 6 values per sphere. Internally a perfect sphere 376 | 377 | 378 | 379 | 380 | # following can be or-combined 381 | sim_particle_respondable1to4 =0x0020 # the particles are respondable against shapes (against all objects that have at least one bit 1-4 activated in the global respondable mask) 382 | sim_particle_respondable5to8 =0x0040 # the particles are respondable against shapes (against all objects that have at least one bit 5-8 activated in the global respondable mask) 383 | sim_particle_particlerespondable =0x0080 # the particles are respondable against each other 384 | sim_particle_ignoresgravity =0x0100 # the particles ignore the effect of gravity. Not compatible with sim_particle_water 385 | sim_particle_invisible =0x0200 # the particles are invisible 386 | sim_particle_itemsizes =0x0400 # +1 value per particle (each particle can have a different size) 387 | sim_particle_itemdensities =0x0800 # +1 value per particle (each particle can have a different density) 388 | sim_particle_itemcolors =0x1000 # +3 values per particle (each particle can have a different color) 389 | sim_particle_cyclic =0x2000 # if the max item count was reached then the first items are overwritten. 390 | sim_particle_emissioncolor =0x4000 # When used in combination with sim_particle_itemcolors then the specified colors will be for the emissive component 391 | sim_particle_water =0x8000 # the particles are water particles (no weight in the water (i.e. when z<0)). Not compatible with sim_particle_ignoresgravity 392 | sim_particle_painttag =0x10000 # The particles can be seen by vision sensors (sim_particle_invisible must not be set) 393 | 394 | 395 | 396 | 397 | # custom user interface menu attributes 398 | sim_ui_menu_title =1 399 | sim_ui_menu_minimize =2 400 | sim_ui_menu_close =4 401 | sim_ui_menu_systemblock =8 402 | 403 | 404 | 405 | # Boolean parameters 406 | sim_boolparam_hierarchy_visible =0 407 | sim_boolparam_console_visible =1 408 | sim_boolparam_collision_handling_enabled =2 409 | sim_boolparam_distance_handling_enabled =3 410 | sim_boolparam_ik_handling_enabled =4 411 | sim_boolparam_gcs_handling_enabled =5 412 | sim_boolparam_dynamics_handling_enabled =6 413 | sim_boolparam_joint_motion_handling_enabled =7 414 | sim_boolparam_path_motion_handling_enabled =8 415 | sim_boolparam_proximity_sensor_handling_enabled =9 416 | sim_boolparam_vision_sensor_handling_enabled =10 417 | sim_boolparam_mill_handling_enabled =11 418 | sim_boolparam_browser_visible =12 419 | sim_boolparam_scene_and_model_load_messages =13 420 | sim_reserved0 =14 421 | sim_boolparam_shape_textures_are_visible =15 422 | sim_boolparam_display_enabled =16 423 | sim_boolparam_infotext_visible =17 424 | sim_boolparam_statustext_open =18 425 | sim_boolparam_fog_enabled =19 426 | sim_boolparam_rml2_available =20 427 | sim_boolparam_rml4_available =21 428 | sim_boolparam_mirrors_enabled =22 429 | sim_boolparam_aux_clip_planes_enabled =23 430 | sim_boolparam_full_model_copy_from_api =24 431 | sim_boolparam_realtime_simulation =25 432 | sim_boolparam_force_show_wireless_emission =27 433 | sim_boolparam_force_show_wireless_reception =28 434 | sim_boolparam_video_recording_triggered =29 435 | sim_boolparam_threaded_rendering_enabled =32 436 | sim_boolparam_fullscreen =33 437 | sim_boolparam_headless =34 438 | sim_boolparam_hierarchy_toolbarbutton_enabled =35 439 | sim_boolparam_browser_toolbarbutton_enabled =36 440 | sim_boolparam_objectshift_toolbarbutton_enabled =37 441 | sim_boolparam_objectrotate_toolbarbutton_enabled=38 442 | sim_boolparam_force_calcstruct_all_visible =39 443 | sim_boolparam_force_calcstruct_all =40 444 | sim_boolparam_exit_request =41 445 | sim_boolparam_play_toolbarbutton_enabled =42 446 | sim_boolparam_pause_toolbarbutton_enabled =43 447 | sim_boolparam_stop_toolbarbutton_enabled =44 448 | sim_boolparam_waiting_for_trigger =45 449 | 450 | 451 | # Integer parameters 452 | sim_intparam_error_report_mode =0 # Check sim_api_errormessage_... constants above for valid values 453 | sim_intparam_program_version =1 # e.g Version 2.1.4 --> 20104. Can only be read 454 | sim_intparam_instance_count =2 # do not use anymore (always returns 1 since CoppeliaSim 2.5.11) 455 | sim_intparam_custom_cmd_start_id =3 # can only be read 456 | sim_intparam_compilation_version =4 # 0=evaluation version 1=full version 2=player version. Can only be read 457 | sim_intparam_current_page =5 458 | sim_intparam_flymode_camera_handle =6 # can only be read 459 | sim_intparam_dynamic_step_divider =7 # can only be read 460 | sim_intparam_dynamic_engine =8 # 0=Bullet 1=ODE. 2=Vortex. 461 | sim_intparam_server_port_start =9 # can only be read 462 | sim_intparam_server_port_range =10 # can only be read 463 | sim_intparam_visible_layers =11 464 | sim_intparam_infotext_style =12 465 | sim_intparam_settings =13 466 | sim_intparam_edit_mode_type =14 # can only be read 467 | sim_intparam_server_port_next =15 # is initialized at sim_intparam_server_port_start 468 | sim_intparam_qt_version =16 # version of the used Qt framework 469 | sim_intparam_event_flags_read =17 # can only be read 470 | sim_intparam_event_flags_read_clear =18 # can only be read 471 | sim_intparam_platform =19 # can only be read 472 | sim_intparam_scene_unique_id =20 # can only be read 473 | sim_intparam_work_thread_count =21 474 | sim_intparam_mouse_x =22 475 | sim_intparam_mouse_y =23 476 | sim_intparam_core_count =24 477 | sim_intparam_work_thread_calc_time_ms =25 478 | sim_intparam_idle_fps =26 479 | sim_intparam_prox_sensor_select_down =27 480 | sim_intparam_prox_sensor_select_up =28 481 | sim_intparam_stop_request_counter =29 482 | sim_intparam_program_revision =30 483 | sim_intparam_mouse_buttons =31 484 | sim_intparam_dynamic_warning_disabled_mask =32 485 | sim_intparam_simulation_warning_disabled_mask =33 486 | sim_intparam_scene_index =34 487 | sim_intparam_motionplanning_seed =35 488 | sim_intparam_speedmodifier =36 489 | 490 | # Float parameters 491 | sim_floatparam_rand=0 # random value (0.0-1.0) 492 | sim_floatparam_simulation_time_step =1 493 | sim_floatparam_stereo_distance =2 494 | 495 | # String parameters 496 | sim_stringparam_application_path=0 # path of CoppeliaSim's executable 497 | sim_stringparam_video_filename=1 498 | sim_stringparam_app_arg1 =2 499 | sim_stringparam_app_arg2 =3 500 | sim_stringparam_app_arg3 =4 501 | sim_stringparam_app_arg4 =5 502 | sim_stringparam_app_arg5 =6 503 | sim_stringparam_app_arg6 =7 504 | sim_stringparam_app_arg7 =8 505 | sim_stringparam_app_arg8 =9 506 | sim_stringparam_app_arg9 =10 507 | sim_stringparam_scene_path_and_name =13 508 | 509 | # Array parameters 510 | sim_arrayparam_gravity =0 511 | sim_arrayparam_fog =1 512 | sim_arrayparam_fog_color =2 513 | sim_arrayparam_background_color1=3 514 | sim_arrayparam_background_color2=4 515 | sim_arrayparam_ambient_light =5 516 | sim_arrayparam_random_euler =6 517 | 518 | sim_objintparam_visibility_layer= 10 519 | sim_objfloatparam_abs_x_velocity= 11 520 | sim_objfloatparam_abs_y_velocity= 12 521 | sim_objfloatparam_abs_z_velocity= 13 522 | sim_objfloatparam_abs_rot_velocity= 14 523 | sim_objfloatparam_objbbox_min_x= 15 524 | sim_objfloatparam_objbbox_min_y= 16 525 | sim_objfloatparam_objbbox_min_z= 17 526 | sim_objfloatparam_objbbox_max_x= 18 527 | sim_objfloatparam_objbbox_max_y= 19 528 | sim_objfloatparam_objbbox_max_z= 20 529 | sim_objfloatparam_modelbbox_min_x= 21 530 | sim_objfloatparam_modelbbox_min_y= 22 531 | sim_objfloatparam_modelbbox_min_z= 23 532 | sim_objfloatparam_modelbbox_max_x= 24 533 | sim_objfloatparam_modelbbox_max_y= 25 534 | sim_objfloatparam_modelbbox_max_z= 26 535 | sim_objintparam_collection_self_collision_indicator= 27 536 | sim_objfloatparam_transparency_offset= 28 537 | sim_objintparam_child_role= 29 538 | sim_objintparam_parent_role= 30 539 | sim_objintparam_manipulation_permissions= 31 540 | sim_objintparam_illumination_handle= 32 541 | 542 | sim_visionfloatparam_near_clipping= 1000 543 | sim_visionfloatparam_far_clipping= 1001 544 | sim_visionintparam_resolution_x= 1002 545 | sim_visionintparam_resolution_y= 1003 546 | sim_visionfloatparam_perspective_angle= 1004 547 | sim_visionfloatparam_ortho_size= 1005 548 | sim_visionintparam_disabled_light_components= 1006 549 | sim_visionintparam_rendering_attributes= 1007 550 | sim_visionintparam_entity_to_render= 1008 551 | sim_visionintparam_windowed_size_x= 1009 552 | sim_visionintparam_windowed_size_y= 1010 553 | sim_visionintparam_windowed_pos_x= 1011 554 | sim_visionintparam_windowed_pos_y= 1012 555 | sim_visionintparam_pov_focal_blur= 1013 556 | sim_visionfloatparam_pov_blur_distance= 1014 557 | sim_visionfloatparam_pov_aperture= 1015 558 | sim_visionintparam_pov_blur_sampled= 1016 559 | sim_visionintparam_render_mode= 1017 560 | 561 | sim_jointintparam_motor_enabled= 2000 562 | sim_jointintparam_ctrl_enabled= 2001 563 | sim_jointfloatparam_pid_p= 2002 564 | sim_jointfloatparam_pid_i= 2003 565 | sim_jointfloatparam_pid_d= 2004 566 | sim_jointfloatparam_intrinsic_x= 2005 567 | sim_jointfloatparam_intrinsic_y= 2006 568 | sim_jointfloatparam_intrinsic_z= 2007 569 | sim_jointfloatparam_intrinsic_qx= 2008 570 | sim_jointfloatparam_intrinsic_qy= 2009 571 | sim_jointfloatparam_intrinsic_qz= 2010 572 | sim_jointfloatparam_intrinsic_qw= 2011 573 | sim_jointfloatparam_velocity= 2012 574 | sim_jointfloatparam_spherical_qx= 2013 575 | sim_jointfloatparam_spherical_qy= 2014 576 | sim_jointfloatparam_spherical_qz= 2015 577 | sim_jointfloatparam_spherical_qw= 2016 578 | sim_jointfloatparam_upper_limit= 2017 579 | sim_jointfloatparam_kc_k= 2018 580 | sim_jointfloatparam_kc_c= 2019 581 | sim_jointfloatparam_ik_weight= 2021 582 | sim_jointfloatparam_error_x= 2022 583 | sim_jointfloatparam_error_y= 2023 584 | sim_jointfloatparam_error_z= 2024 585 | sim_jointfloatparam_error_a= 2025 586 | sim_jointfloatparam_error_b= 2026 587 | sim_jointfloatparam_error_g= 2027 588 | sim_jointfloatparam_error_pos= 2028 589 | sim_jointfloatparam_error_angle= 2029 590 | sim_jointintparam_velocity_lock= 2030 591 | sim_jointintparam_vortex_dep_handle= 2031 592 | sim_jointfloatparam_vortex_dep_multiplication= 2032 593 | sim_jointfloatparam_vortex_dep_offset= 2033 594 | 595 | sim_shapefloatparam_init_velocity_x= 3000 596 | sim_shapefloatparam_init_velocity_y= 3001 597 | sim_shapefloatparam_init_velocity_z= 3002 598 | sim_shapeintparam_static= 3003 599 | sim_shapeintparam_respondable= 3004 600 | sim_shapefloatparam_mass= 3005 601 | sim_shapefloatparam_texture_x= 3006 602 | sim_shapefloatparam_texture_y= 3007 603 | sim_shapefloatparam_texture_z= 3008 604 | sim_shapefloatparam_texture_a= 3009 605 | sim_shapefloatparam_texture_b= 3010 606 | sim_shapefloatparam_texture_g= 3011 607 | sim_shapefloatparam_texture_scaling_x= 3012 608 | sim_shapefloatparam_texture_scaling_y= 3013 609 | sim_shapeintparam_culling= 3014 610 | sim_shapeintparam_wireframe= 3015 611 | sim_shapeintparam_compound= 3016 612 | sim_shapeintparam_convex= 3017 613 | sim_shapeintparam_convex_check= 3018 614 | sim_shapeintparam_respondable_mask= 3019 615 | sim_shapefloatparam_init_velocity_a= 3020 616 | sim_shapefloatparam_init_velocity_b= 3021 617 | sim_shapefloatparam_init_velocity_g= 3022 618 | sim_shapestringparam_color_name= 3023 619 | sim_shapeintparam_edge_visibility= 3024 620 | sim_shapefloatparam_shading_angle= 3025 621 | sim_shapefloatparam_edge_angle= 3026 622 | sim_shapeintparam_edge_borders_hidden= 3027 623 | 624 | sim_proxintparam_ray_invisibility= 4000 625 | 626 | sim_forcefloatparam_error_x= 5000 627 | sim_forcefloatparam_error_y= 5001 628 | sim_forcefloatparam_error_z= 5002 629 | sim_forcefloatparam_error_a= 5003 630 | sim_forcefloatparam_error_b= 5004 631 | sim_forcefloatparam_error_g= 5005 632 | sim_forcefloatparam_error_pos= 5006 633 | sim_forcefloatparam_error_angle= 5007 634 | 635 | sim_lightintparam_pov_casts_shadows= 8000 636 | 637 | sim_cameraintparam_disabled_light_components= 9000 638 | sim_camerafloatparam_perspective_angle= 9001 639 | sim_camerafloatparam_ortho_size= 9002 640 | sim_cameraintparam_rendering_attributes= 9003 641 | sim_cameraintparam_pov_focal_blur= 9004 642 | sim_camerafloatparam_pov_blur_distance= 9005 643 | sim_camerafloatparam_pov_aperture= 9006 644 | sim_cameraintparam_pov_blur_samples= 9007 645 | 646 | sim_dummyintparam_link_type= 10000 647 | 648 | sim_mirrorfloatparam_width= 12000 649 | sim_mirrorfloatparam_height= 12001 650 | sim_mirrorfloatparam_reflectance= 12002 651 | sim_mirrorintparam_enable= 12003 652 | 653 | sim_pplanfloatparam_x_min= 20000 654 | sim_pplanfloatparam_x_range= 20001 655 | sim_pplanfloatparam_y_min= 20002 656 | sim_pplanfloatparam_y_range= 20003 657 | sim_pplanfloatparam_z_min= 20004 658 | sim_pplanfloatparam_z_range= 20005 659 | sim_pplanfloatparam_delta_min= 20006 660 | sim_pplanfloatparam_delta_range= 20007 661 | 662 | sim_mplanintparam_nodes_computed= 25000 663 | sim_mplanintparam_prepare_nodes= 25001 664 | sim_mplanintparam_clear_nodes= 25002 665 | 666 | # User interface elements 667 | sim_gui_menubar =0x0001 668 | sim_gui_popups =0x0002 669 | sim_gui_toolbar1 =0x0004 670 | sim_gui_toolbar2 =0x0008 671 | sim_gui_hierarchy =0x0010 672 | sim_gui_infobar =0x0020 673 | sim_gui_statusbar =0x0040 674 | sim_gui_scripteditor =0x0080 675 | sim_gui_scriptsimulationparameters =0x0100 676 | sim_gui_dialogs =0x0200 677 | sim_gui_browser =0x0400 678 | sim_gui_all =0xffff 679 | 680 | 681 | # Joint modes 682 | sim_jointmode_passive =0 683 | sim_jointmode_motion =1 684 | sim_jointmode_ik =2 685 | sim_jointmode_ikdependent =3 686 | sim_jointmode_dependent =4 687 | sim_jointmode_force =5 688 | 689 | 690 | # Navigation and selection modes with the mouse. Lower byte values are mutually exclusive upper byte bits can be combined 691 | sim_navigation_passive =0x0000 692 | sim_navigation_camerashift =0x0001 693 | sim_navigation_camerarotate =0x0002 694 | sim_navigation_camerazoom =0x0003 695 | sim_navigation_cameratilt =0x0004 696 | sim_navigation_cameraangle =0x0005 697 | sim_navigation_camerafly =0x0006 698 | sim_navigation_objectshift =0x0007 699 | sim_navigation_objectrotate =0x0008 700 | sim_navigation_reserved2 =0x0009 701 | sim_navigation_reserved3 =0x000A 702 | sim_navigation_jointpathtest =0x000B 703 | sim_navigation_ikmanip =0x000C 704 | sim_navigation_objectmultipleselection =0x000D 705 | # Bit-combine following values and add them to one of above's values for a valid navigation mode 706 | sim_navigation_reserved4 =0x0100 707 | sim_navigation_clickselection =0x0200 708 | sim_navigation_ctrlselection =0x0400 709 | sim_navigation_shiftselection =0x0800 710 | sim_navigation_camerazoomwheel =0x1000 711 | sim_navigation_camerarotaterightbutton =0x2000 712 | 713 | 714 | 715 | #Remote API constants 716 | SIMX_VERSION =0 717 | # Remote API message header structure 718 | SIMX_HEADER_SIZE =18 719 | simx_headeroffset_crc =0 # 1 simxUShort. Generated by the client or server. The CRC for the message 720 | simx_headeroffset_version =2 # 1 byte. Generated by the client or server. The version of the remote API software 721 | simx_headeroffset_message_id =3 # 1 simxInt. Generated by the client (and used in a reply by the server) 722 | simx_headeroffset_client_time =7 # 1 simxInt. Client time stamp generated by the client (and sent back by the server) 723 | simx_headeroffset_server_time =11 # 1 simxInt. Generated by the server when a reply is generated. The server timestamp 724 | simx_headeroffset_scene_id =15 # 1 simxUShort. Generated by the server. A unique ID identifying the scene currently displayed 725 | simx_headeroffset_server_state =17 # 1 byte. Generated by the server. Bit coded 0 set --> simulation not stopped 1 set --> simulation paused 2 set --> real-time switch on 3-5 edit mode type (0=no edit mode 1=triangle 2=vertex 3=edge 4=path 5=UI) 726 | 727 | # Remote API command header 728 | SIMX_SUBHEADER_SIZE =26 729 | simx_cmdheaderoffset_mem_size =0 # 1 simxInt. Generated by the client or server. The buffer size of the command. 730 | simx_cmdheaderoffset_full_mem_size =4 # 1 simxInt. Generated by the client or server. The full buffer size of the command (applies to split chunks). 731 | simx_cmdheaderoffset_pdata_offset0 =8 # 1 simxUShort. Generated by the client or server. The amount of data that is part of the command identification. 732 | simx_cmdheaderoffset_pdata_offset1 =10 # 1 simxInt. Generated by the client or server. The amount of shift of the pure data buffer (applies to split chunks). 733 | simx_cmdheaderoffset_cmd=14 # 1 simxInt. Generated by the client (and used in a reply by the server). The command combined with the operation mode of the command. 734 | simx_cmdheaderoffset_delay_or_split =18 # 1 simxUShort. Generated by the client or server. The amount of delay in ms of a continuous command or the max. pure data size to send at once (applies to split commands). 735 | simx_cmdheaderoffset_sim_time =20 # 1 simxInt. Generated by the server. The simulation time (in ms) when the command was executed (or 0 if simulation is not running) 736 | simx_cmdheaderoffset_status =24 # 1 byte. Generated by the server. (1 bit 0 is set --> error in function execution on server side). The client writes bit 1 if command cannot be overwritten 737 | simx_cmdheaderoffset_reserved =25 # 1 byte. Not yet used 738 | 739 | 740 | 741 | 742 | 743 | # Regular operation modes 744 | simx_opmode_oneshot =0x000000 # sends command as one chunk. Reply will also come as one chunk. Doesn't wait for the reply. 745 | simx_opmode_blocking =0x010000 # sends command as one chunk. Reply will also come as one chunk. Waits for the reply (_REPLY_WAIT_TIMEOUT_IN_MS is the timeout). 746 | simx_opmode_oneshot_wait =0x010000 # sends command as one chunk. Reply will also come as one chunk. Waits for the reply (_REPLY_WAIT_TIMEOUT_IN_MS is the timeout). 747 | simx_opmode_continuous =0x020000 748 | simx_opmode_streaming =0x020000 # sends command as one chunk. Command will be stored on the server and always executed 749 | #(every x ms (as far as possible) where x can be 0-65535. just add x to opmode_continuous). 750 | # A reply will be sent continuously each time as one chunk. Doesn't wait for the reply. 751 | 752 | # Operation modes for heavy data 753 | simx_opmode_oneshot_split =0x030000 # sends command as several chunks (max chunk size is x bytes where x can be _MIN_SPLIT_AMOUNT_IN_BYTES-65535. Just add x to opmode_oneshot_split). Reply will also come as several chunks. Doesn't wait for the reply. 754 | simx_opmode_continuous_split =0x040000 755 | simx_opmode_streaming_split =0x040000 # sends command as several chunks (max chunk size is x bytes where x can be _MIN_SPLIT_AMOUNT_IN_BYTES-65535. Just add x to opmode_continuous_split). Command will be stored on the server and always executed. A reply will be sent continuously each time as several chunks. Doesn't wait for the reply. 756 | 757 | # Special operation modes 758 | simx_opmode_discontinue =0x050000 # removes and cancels all commands stored on the client or server side (also continuous commands) 759 | simx_opmode_buffer =0x060000 # doesn't send anything but checks if a reply for the given command is available in the input buffer (i.e. previously received from the server) 760 | simx_opmode_remove =0x070000 # doesn't send anything and doesn't return any specific value. It just erases a similar command reply in the inbox (to free some memory) 761 | 762 | 763 | # Command return codes 764 | simx_return_ok =0x000000 765 | simx_return_novalue_flag =0x000001 # input buffer doesn't contain the specified command 766 | simx_return_timeout_flag =0x000002 # command reply not received in time for opmode_oneshot_wait operation mode 767 | simx_return_illegal_opmode_flag =0x000004 # command doesn't support the specified operation mode 768 | simx_return_remote_error_flag =0x000008 # command caused an error on the server side 769 | simx_return_split_progress_flag =0x000010 # previous similar command not yet fully processed (applies to opmode_oneshot_split operation modes) 770 | simx_return_local_error_flag =0x000020 # command caused an error on the client side 771 | simx_return_initialize_error_flag =0x000040 # simxStart was not yet called 772 | 773 | # Following for backward compatibility (same as above) 774 | simx_error_noerror =0x000000 775 | simx_error_novalue_flag =0x000001 # input buffer doesn't contain the specified command 776 | simx_error_timeout_flag =0x000002 # command reply not received in time for opmode_oneshot_wait operation mode 777 | simx_error_illegal_opmode_flag =0x000004 # command doesn't support the specified operation mode 778 | simx_error_remote_error_flag =0x000008 # command caused an error on the server side 779 | simx_error_split_progress_flag =0x000010 # previous similar command not yet fully processed (applies to opmode_oneshot_split operation modes) 780 | simx_error_local_error_flag =0x000020 # command caused an error on the client side 781 | simx_error_initialize_error_flag =0x000040 # simxStart was not yet called 782 | 783 | 784 | --------------------------------------------------------------------------------