Commit bbf907cf authored by Ibrahim Ahmed's avatar Ibrahim Ahmed
Browse files

got simulink integration working

parent 66c1fc05
*.o
*.so
*.bin
plugins/*/build
\ No newline at end of file
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
\ No newline at end of file
......@@ -8,6 +8,10 @@
* [VM for Gazebo 9, ROS Melodic, Gazebo-ROS plugin](https://www.mathworks.com/ros2_vm_install/v2)
* [Perform Co-Simulation between Simulink and Gazebo](https://www.mathworks.com/help/robotics/examples/perform-co-simulation-between-simulink-and-gazebo.html)
## Reference
* [Gazebo Simulation Description Format (SDF) specification](http://sdformat.org). This is used to describe model and world files.
## Setup
......
......@@ -7,5 +7,5 @@
"path": "../../src/GazeboPlugin"
}
],
"settings": {}
"settings": {},
}
\ No newline at end of file
<sdf version="1.5">
<model name="my_model">
<model name="box">
<pose>0 0 0.5 0 0 0</pose>
<static>true</static>
<static>false</static>
<link name="link">
<inertial>
<mass>1.0</mass>
<inertia> <!-- inertias are tricky to compute -->
<!-- http://gazebosim.org/tutorials?tut=inertia&cat=build_robot -->
<ixx>0.083</ixx> <!-- for a box: ixx = 0.083 * mass * (y*y + z*z) -->
<ixy>0.0</ixy> <!-- for a box: ixy = 0 -->
<ixz>0.0</ixz> <!-- for a box: ixz = 0 -->
<iyy>0.083</iyy> <!-- for a box: iyy = 0.083 * mass * (x*x + z*z) -->
<iyz>0.0</iyz> <!-- for a box: iyz = 0 -->
<izz>0.083</izz> <!-- for a box: izz = 0.083 * mass * (x*x + y*y) -->
</inertia>
</inertial>
<collision name="collision">
<geometry>
......@@ -21,6 +12,14 @@
<size>1 1 1</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0</mu>
<mu2>0</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
......
<?xml version="1.0"?>
<model>
<name>Test</name>
<name>Box</name>
<version>1.0</version>
<sdf version='1.5'>model.sdf</sdf>
<sdf version='1.5'>box.sdf</sdf>
<author>
<name>Ibrahim Ahmed</name>
......
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")
add_library(hello_world SHARED hello_world.cc)
target_link_libraries(hello_world ${GAZEBO_LIBRARIES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")
\ No newline at end of file
#include <gazebo/gazebo.hh>
namespace gazebo
{
class WorldPluginTutorial : public WorldPlugin
{
public: WorldPluginTutorial() : WorldPlugin()
{
printf("Hello World!\n");
}
public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
{
}
};
GZ_REGISTER_WORLD_PLUGIN(WorldPluginTutorial)
}
\ No newline at end of file
source /usr/share/gazebo/setup.sh
export GAZEBO_MODEL_PATH=~/src/gazebo_models/:${GAZEBO_MODEL_PATH}
# https://stackoverflow.com/a/9107028/4591810
SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"
export GAZEBO_MODEL_PATH=${SCRIPTPATH}/models/:~/src/gazebo_models/:${GAZEBO_MODEL_PATH}
export GAZEBO_PLUGIN_PATH=~/src/GazeboPlugin/export/lib/:${GAZEBO_PLUGIN_PATH}
\ No newline at end of file
......@@ -85,10 +85,20 @@
<heading_deg>0</heading_deg>
</spherical_coordinates>
<state world_name='default'>
<sim_time>49 234000000</sim_time>
<real_time>49 322939707</real_time>
<wall_time>1594912600 184850417</wall_time>
<iterations>49234</iterations>
<sim_time>0 0</sim_time>
<real_time>0 0</real_time>
<wall_time>1595535602 92402342</wall_time>
<iterations>0</iterations>
<model name='box'>
<pose frame=''>0.141198 -0.126775 0.5 0 -0 0</pose>
<scale>1 1 1</scale>
<link name='link'>
<pose frame=''>0.141198 -0.126775 0.5 0 -0 0</pose>
<velocity>0 0 0 0 -0 0</velocity>
<acceleration>-10 -10 -3.74987 0 -0 0</acceleration>
<wrench>-10 -10 -3.74987 0 -0 0</wrench>
</link>
</model>
<model name='ground_plane'>
<pose frame=''>0 0 0 0 -0 0</pose>
<scale>1 1 1</scale>
......@@ -99,16 +109,126 @@
<wrench>0 0 0 0 -0 0</wrench>
</link>
</model>
<model name='quadrotor'>
<pose frame=''>-0.908023 -2.26733 0 0 -0 0</pose>
<scale>1 1 1</scale>
<link name='link'>
<pose frame=''>-0.908023 -2.26733 0.182466 0 -0 0</pose>
<velocity>0 0 0 0 -0 0</velocity>
<acceleration>5.94883 -2.10183 1.00698 -2.48923 0.793794 1.07665</acceleration>
<wrench>7.82866 -2.766 1.32518 0 -0 0</wrench>
</link>
</model>
<light name='sun'>
<pose frame=''>0 0 10 0 -0 0</pose>
</light>
</state>
<gui fullscreen='0'>
<camera name='user_camera'>
<pose frame=''>5 -5 2 0 0.275643 2.35619</pose>
<pose frame=''>8.65722 -16.059 8.3735 -0 0.371643 2.02419</pose>
<view_controller>orbit</view_controller>
<projection_type>perspective</projection_type>
</camera>
</gui>
<plugin name='GazeboPlugin' filename='libGazeboCoSimPlugin.so'>
<portNumber>14581</portNumber>
</plugin>
<model name='box'>
<pose frame=''>0.141198 -0.126775 0.5 0 -0 0</pose>
<static>0</static>
<link name='link'>
<inertial>
<mass>1</mass>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
</inertial>
<collision name='collision'>
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0</mu>
<mu2>0</mu2>
</ode>
<torsional>
<ode/>
</torsional>
</friction>
<contact>
<ode/>
</contact>
<bounce/>
</surface>
<max_contacts>10</max_contacts>
</collision>
<visual name='visual'>
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</visual>
<self_collide>0</self_collide>
<enable_wind>0</enable_wind>
<kinematic>0</kinematic>
</link>
</model>
<model name='quadrotor'>
<link name='link'>
<pose frame=''>0 0 0.182466 0 -0 0</pose>
<inertial>
<mass>1.316</mass>
<inertia>
<ixx>0.0128</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.0128</iyy>
<iyz>0</iyz>
<izz>0.0218</izz>
</inertia>
</inertial>
<collision name='collision'>
<geometry>
<mesh>
<uri>model://quadrotor/meshes/quadrotor_base.dae</uri>
</mesh>
</geometry>
<max_contacts>10</max_contacts>
<surface>
<contact>
<ode/>
</contact>
<bounce/>
<friction>
<torsional>
<ode/>
</torsional>
<ode/>
</friction>
</surface>
</collision>
<visual name='visual'>
<geometry>
<mesh>
<uri>model://quadrotor/meshes/quadrotor_base.dae</uri>
</mesh>
</geometry>
</visual>
<self_collide>0</self_collide>
<enable_wind>0</enable_wind>
<kinematic>0</kinematic>
</link>
<pose frame=''>-0.908023 -2.26733 0 0 -0 0</pose>
</model>
</world>
</sdf>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment