├── README.md
├── setup
└── install_geographiclib_datasets.sh
├── underwater_sensor_msgs
├── CHANGELOG.rst
├── CMakeLists.txt
├── msg
│ ├── DVL.msg
│ ├── LedLight.msg
│ └── Pressure.msg
├── package.xml
└── srv
│ └── SpawnMarker.srv
├── underwater_vehicle_dynamics
├── CHANGELOG.rst
├── CMakeLists.txt
├── Makefile
├── config
│ └── dynamics_g500.yaml
├── launch
│ ├── UWSim_g500_dynamics.launch
│ └── dynamics.launch
├── mainpage.dox
├── package.xml
└── src
│ ├── dynamics.py
│ └── keyboard.py
└── uwsim
├── CHANGELOG.rst
├── CMakeLists.txt
├── cmake
└── Modules
│ ├── CheckGeographicLibDatasets.cmake
│ └── FindGeographicLib.cmake
├── data
├── scenes
│ ├── .vscode
│ │ ├── c_cpp_properties.json
│ │ └── settings.json
│ ├── UWSimScene.dtd
│ ├── cirs.xml
│ ├── cirs_sls.xml
│ ├── cirs_stereo.xml
│ ├── common.xacro
│ ├── deviceLibrary.xacro
│ ├── g500ARM5-rviz.urdf
│ ├── g500ARM5.urdf
│ ├── g500ARM5.urdf.xacro
│ ├── g500ARM5.xml
│ ├── g500ARM5_laser.urdf
│ ├── installScene
│ ├── launch
│ │ ├── .gitignore
│ │ ├── cuba_aruco.launch
│ │ ├── cuba_aruco.rviz
│ │ ├── demo-hil.launch
│ │ ├── demo-sitl.launch
│ │ └── netsim_cirs.launch
│ ├── objectLibrary.xacro
│ ├── r2d2.urdf
│ ├── shapesTest.xml
│ ├── ship.xml
│ ├── ship_scene.xml
│ ├── shipwreck.xml
│ ├── ujione-rviz.urdf
│ ├── ujione.urdf
│ ├── ujione.xml
│ ├── vehicleLibrary.xacro
│ └── xacroExample.xml.xacro
└── shaders
│ ├── default_scene.frag
│ └── default_scene.vert
├── include
└── uwsim
│ ├── AcousticCommsChannel.h
│ ├── AcousticCommsDevice.h
│ ├── BulletPhysics.h
│ ├── CommsDevice.h
│ ├── ConfigXMLParser.h
│ ├── CustomCommsChannel.h
│ ├── CustomCommsDevice.h
│ ├── CustomWidget.h
│ ├── DVLSensor.h
│ ├── DredgeTool.h
│ ├── EventHandler.h
│ ├── ForceSensor.h
│ ├── GPSSensor.h
│ ├── HUDCamera.h
│ ├── InertialMeasurementUnit.h
│ ├── KinematicChain.h
│ ├── LedArray.h
│ ├── MultibeamSensor.h
│ ├── NED.h
│ ├── NetSim.h
│ ├── ObjectPicker.h
│ ├── PhysicsBuilder.h
│ ├── PressureSensor.h
│ ├── ROSInterface.h
│ ├── ROSSceneBuilder.h
│ ├── SceneBuilder.h
│ ├── SimDev_Echo.h
│ ├── SimulatedDevice.h
│ ├── SimulatedDevices.h
│ ├── SimulatedIAUV.h
│ ├── SimulatorConfig.h.cmake
│ ├── SkyDome.h
│ ├── SphereSegment.h
│ ├── TextHUD.h
│ ├── TrajectoryVisualization.h
│ ├── URDFRobot.h
│ ├── UWSimUtils.h
│ ├── ViewBuilder.h
│ ├── VirtualCamera.h
│ ├── VirtualRangeSensor.h
│ ├── VirtualSLSProjector.h
│ ├── osgOceanScene.h
│ └── osgPCDLoader.h
├── interface_examples
├── followMarker.cpp
├── gotoAbsolutePose.cpp
├── gotoRelativePose.cpp
├── makeVehicleSurvey.cpp
├── setJointPosition.cpp
├── setJointVelocity.cpp
├── setVehicleActuators.cpp
├── setVehicleDisturbances.cpp
├── setVehiclePose.cpp
├── setVehiclePosition.cpp
├── setVehicleTwist.cpp
├── setVehicleVelocity.cpp
└── spawnMarker.cpp
├── license.txt
├── package.xml
├── saveDataFile.sh
├── simdev_plugins.xml
└── src
├── AcousticCommsChannel.cpp
├── AcousticCommsDevice.cpp
├── BulletPhysics.cpp
├── CommsDevice.cpp
├── ConfigXMLParser.cpp
├── CustomCommsChannel.cpp
├── CustomCommsDevice.cpp
├── DVLSensor.cpp
├── DredgeTool.cpp
├── ForceSensor.cpp
├── GPSSensor.cpp
├── HUDCamera.cpp
├── InertialMeasurementUnit.cpp
├── KinematicChain.cpp
├── LedArray.cpp
├── MultibeamSensor.cpp
├── NED.cpp
├── NetSim.cpp
├── ObjectPicker.cpp
├── PhysicsBuilder.cpp
├── PressureSensor.cpp
├── ROSInterface.cpp
├── ROSSceneBuilder.cpp
├── SceneBuilder.cpp
├── SimDev_Echo.cpp
├── SimulatedDevices.cpp
├── SimulatedIAUV.cpp
├── SkyDome.cpp
├── SphereSegment.cpp
├── URDFRobot.cpp
├── UWSimUtils.cpp
├── ViewBuilder.cpp
├── VirtualCamera.cpp
├── VirtualRangeSensor.cpp
├── VirtualSLSProjector.cpp
├── main.cpp
├── osgOceanScene.cpp
├── osgPCDLoader.cpp
└── uwsim
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # UWSim-NET: UWSim with Network Simulator
3 | [](http://build.ros.org/job/Mbin_uB64__uwsim__ubuntu_bionic_amd64__binary/)
4 |
5 | The new version of UWSim intregates a Network Simulator to be used along with the dccomms API. This simulator uses the NS3 libraries and the AquaSimNG as a NS3 module. The documentation related to simulate communications is a work in progress and will be included in the Wiki as soon as we can (please, be patience).
6 |
7 | ### Wiki
8 | http://www.irs.uji.es/uwsim/wiki/index.php?title=Main_Page
9 |
10 | ### Citations
11 | - Prats, M.; Perez, J.; Fernandez, J.J.; Sanz, P.J., "An open source tool for simulation and supervision of underwater intervention missions", 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 2577-2582, 7-12 Oct. 2012
12 | - Centelles, D.; Soriano-Asensi, A.; Martí, J.V.; Marín, R.; Sanz, P.J. Underwater Wireless Communications for Cooperative Robotics with UWSim-NET. Appl. Sci. 2019, 9, 3526.
13 |
14 | ### Issues
15 |
16 | #### Exception GeographicLib::GeographicErr when starting uwsim
17 |
18 | If you are getting the following error output when executing rosrun uwsim uwsim:
19 | ```
20 | ...
21 | data/objects/gun.osg
22 | Starting UWSim...
23 | Loading SimulatedDevices plugin: 'AcousticCommsDevice_Factory'
24 | Loading SimulatedDevices plugin: 'CustomCommsDevice_Factory'
25 | Loading SimulatedDevices plugin: 'DredgeTool_Factory'
26 | Loading SimulatedDevices plugin: 'ForceSensor_Factory'
27 | Loading SimulatedDevices plugin: 'SimDev_Echo_Factory'
28 | . Setting localized world: 7.1e-05s
29 | terminate called after throwing an instance of 'GeographicLib::GeographicErr'
30 | what(): File not readable /usr/share/GeographicLib/geoids/egm96-5.pgm
31 | /opt/ros/melodic/lib/uwsim/uwsim: line 23: 1452 Aborted (core dumped) rosrun uwsim uwsim_binary --dataPath ~/.uwsim/data $@
32 | ```
33 |
34 | Run the following commands to fix it:
35 | ```
36 | wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
37 | chmod u+x install_geographiclib_datasets.sh
38 | sudo ./install_geographiclib_datasets.sh
39 | ```
40 |
41 |
42 |
--------------------------------------------------------------------------------
/setup/install_geographiclib_datasets.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Script to install the model datasets required
3 | # to GeographicLib apply certain conversions
4 |
5 | if [[ $UID != 0 ]]; then
6 | echo "This script require root privileges!" 1>&2
7 | exit 1
8 | fi
9 |
10 | # Install datasets
11 | run_get() {
12 | local dir="$1"
13 | local tool="$2"
14 | local model="$3"
15 |
16 | files=$(shopt -s nullglob dotglob; echo /usr/share/GeographicLib/$dir/$model* /usr/local/share/GeographicLib/$dir/$model*)
17 | if (( ${#files} )); then
18 | echo "GeographicLib $tool dataset $model already exists, skipping"
19 | return
20 | fi
21 |
22 | echo "Installing GeographicLib $tool $model"
23 | geographiclib-get-$tool $model >/dev/null 2>&1
24 | }
25 |
26 | # check which command script is available
27 | if hash geographiclib-get-geoids; then
28 | run_get geoids geoids egm96-5
29 | run_get gravity gravity egm96
30 | run_get magnetic magnetic emm2015
31 | elif hash geographiclib-datasets-download; then # only allows install the goid model dataset
32 | geographiclib-datasets-download egm96_5;
33 | else
34 | echo "OS not supported! Check GeographicLib page for supported OS and lib versions." 1>&2
35 | fi
36 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package underwater_sensor_msgs
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.4.1 (2015-12-14)
6 | ------------------
7 |
8 | 1.4.0 (2015-09-23)
9 | ------------------
10 | * Added marker service to spawn and modify geometry.
11 | * Contributors: perezsolerj
12 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(underwater_sensor_msgs)
3 |
4 | find_package(catkin REQUIRED COMPONENTS message_generation roscpp std_msgs visualization_msgs)
5 |
6 | add_message_files(
7 | FILES
8 | DVL.msg
9 | Pressure.msg
10 | LedLight.msg
11 | )
12 |
13 | add_service_files(
14 | FILES
15 | SpawnMarker.srv
16 | )
17 |
18 | generate_messages(
19 | DEPENDENCIES roscpp std_msgs visualization_msgs
20 | )
21 |
22 | catkin_package(
23 | CATKIN_DEPENDS message_runtime roscpp
24 | )
25 |
26 |
27 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/msg/DVL.msg:
--------------------------------------------------------------------------------
1 | Header header
2 | string header_dvl
3 | string date
4 | float64 salinity
5 | float64 temperature # TODO::ARNAU ha de ser generic ?
6 | float64 depth # TODO::ARNAU ha de ser generic
7 | float64 sound_speed
8 | int32 test
9 | #WATER-MASS, INSTRUMENT-REFERENCED VELOCITY DATA
10 | float64 wi_x_axis
11 | float64 wi_y_axis
12 | float64 wi_z_axis
13 | float64 wi_error
14 | string wi_status
15 | #BOTTOM-TRACK, INSTRUMENT-REFERENCED VELOCITY DATA
16 | float64 bi_x_axis
17 | float64 bi_y_axis
18 | float64 bi_z_axis
19 | float64 bi_error
20 | string bi_status
21 | #WATER-MASS, SHIP-REFERENCED VELOCITY DATA
22 | float64 ws_transverse
23 | float64 ws_longitudinal
24 | float64 ws_normal
25 | string ws_status
26 | #BOTTOM-TRACK, SHIP-REFERENCED VELOCITY DATA
27 | float64 bs_transverse
28 | float64 bs_longitudinal
29 | float64 bs_normal
30 | string bs_status
31 | #WATER-MASS, EARTH-REFERENCED VELOCITY DATA
32 | float64 we_east
33 | float64 we_north
34 | float64 we_upwards
35 | string we_status
36 | #BOTTOM-TRACK, EARTH-REFERENCED VELOCITY DATA
37 | float64 be_east
38 | float64 be_north
39 | float64 be_upwards
40 | string be_status
41 | # WATER-MASS, EARTH-REFERENCED DISTANCE DATA
42 | float64 wd_east
43 | float64 wd_north
44 | float64 wd_upwards
45 | float64 wd_range
46 | float64 wd_time
47 | #BOTTOM-TRACK, EARTH-REFERENCED DISTANCE DATA
48 | float64 bd_east
49 | float64 bd_north
50 | float64 bd_upwards
51 | float64 bd_range
52 | float64 bd_time
53 | #RAW DATA
54 | string raw_data
55 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/msg/LedLight.msg:
--------------------------------------------------------------------------------
1 | duration duration
2 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/msg/Pressure.msg:
--------------------------------------------------------------------------------
1 | Header header
2 | float32 pressure
3 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | underwater_sensor_msgs
4 | 1.4.2
5 | Common messages for underwater robotics
6 |
7 | Mario Prats
8 | Mario Prats
9 | Javier Perez
10 | Diego Centelles
11 |
12 | BSD
13 |
14 | roscpp
15 | message_generation
16 | std_msgs
17 | visualization_msgs
18 | roscpp
19 | message_runtime
20 | std_msgs
21 | visualization_msgs
22 |
23 | catkin
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/underwater_sensor_msgs/srv/SpawnMarker.srv:
--------------------------------------------------------------------------------
1 | visualization_msgs/Marker marker # Marker to spawn/modify/delete
2 | ---
3 | bool success # Returns True if the request was successfull
4 | string status_message # Comments on the request
5 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package underwater_vehicle_dynamics
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.4.1 (2015-12-14)
6 | ------------------
7 |
8 | 1.4.0 (2015-09-23)
9 | ------------------
10 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(underwater_vehicle_dynamics)
3 |
4 | find_package(catkin REQUIRED COMPONENTS rospy std_msgs nav_msgs geometry_msgs sensor_msgs tf tf_conversions
5 | #python_orocos_kdl
6 | )
7 |
8 | catkin_package(
9 | CATKIN_DEPENDS rospy std_msgs nav_msgs geometry_msgs sensor_msgs tf tf_conversions
10 | #python_orocos_kdl
11 | )
12 |
13 | install(PROGRAMS src/dynamics.py
14 | DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
15 |
16 | install(PROGRAMS src/keyboard.py
17 | DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
18 |
19 | install(DIRECTORY launch/
20 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
21 | PATTERN ".svn" EXCLUDE)
22 |
23 | install(DIRECTORY config/
24 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
25 | PATTERN ".svn" EXCLUDE)
26 |
27 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/Makefile:
--------------------------------------------------------------------------------
1 | include $(shell rospack find mk)/cmake.mk
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/config/dynamics_g500.yaml:
--------------------------------------------------------------------------------
1 | # Dynamics model parameters for G500
2 |
3 | g500/num_actuators: 5
4 | g500/dynamics/period: 0.001
5 | g500/dynamics/uwsim_period: 0.001
6 | g500/dynamics/mass: 98.0
7 | g500/dynamics/gravity_center: [0.0, 0.0, 0.05]
8 | g500/dynamics/g: 9.81
9 | g500/dynamics/radius: 0.286
10 |
11 | g500/dynamics/ctf: 0.00006835
12 | g500/dynamics/ctb: 0.00006835
13 |
14 | #Actuator tau for first order actuator dynamic model
15 | g500/dynamics/actuators_tau: [0.2, 0.2, 0.2, 0.2, 0.2]
16 | #Inputs higher than actuators_maxsat will saturate to actuators_maxsat
17 | g500/dynamics/actuators_maxsat: [1, 1, 1, 1, 1]
18 | #Inputs below actuators_minsat will saturate to actuators_minsat
19 | g500/dynamics/actuators_minsat: [-1, -1, -1, -1, -1]
20 | #Inputs to actuators will be scaled to actuators_gain,
21 | g500/dynamics/actuators_gain: [1500, 1500, 1500, 1500, 1500]
22 |
23 | g500/dynamics/dzv: 0.05
24 | g500/dynamics/dv: 0.35
25 | g500/dynamics/dh: 0.4
26 | g500/dynamics/density: 1000.0
27 |
28 | g500/dynamics/tensor: [8.0, 0.0, 0.0, 0.0, 8.0, 0.0, 0.0, 0.0, 8.0]
29 | g500/dynamics/damping: [.0, .0, .0, -130.0, -130.0, -130.0]
30 | g500/dynamics/quadratic_damping: [-148.0, -148.0, -148.0, -180.0, -180.0, -180.0]
31 |
32 | g500/dynamics/Mrb: [ 98.0, 0.0, 0.0, 0.0, 4.9, -0.0,
33 | 0.0, 98.0, 0.0, -4.9, 0.0, 0.0,
34 | 0.0, 0.0, 98.0, 0.0, -0.0, 0.0,
35 | 0.0, -4.9, 0.0, 8.0, 0.0, 0.0,
36 | 4.9, 0.0, -0.0, 0.0, 8.0, 0.0,
37 | -0.0, 0.0, 0.0, 0.0, 0.0, 8.0 ]
38 |
39 | g500/dynamics/Ma: [ 49.0, 0.0, 0.0, 0.0, 0.0, 0.0,
40 | 0.0, 49.0, 0.0, 0.0, 0.0, 0.0,
41 | 0.0, 0.0, 49.0, 0.0, 0.0, 0.0,
42 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
43 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
44 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
45 |
46 | #G500 thrusters.
47 | #Expresion evaluated at each iteration by the python interpreter
48 | #ct is a vector internally defined such that if u[i]>0 then ct[i]=ctf, else ct[i]=ctb, i>=0 and i
2 |
3 |
4 |
5 |
6 | g500/ForceSensor
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/launch/dynamics.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/mainpage.dox:
--------------------------------------------------------------------------------
1 | /**
2 | \mainpage
3 | \htmlinclude manifest.html
4 |
5 | \b underwater_vehicle_dynamics is ...
6 |
7 |
10 |
11 |
12 | \section codeapi Code API
13 |
14 |
24 |
25 |
26 | */
27 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | underwater_vehicle_dynamics
4 | 1.4.2
5 | An underwater dynamics module
6 |
7 | Arnau Carrera
8 | Narcis Palomeras
9 | Mario Prats
10 | Mario Prats
11 | Javier Perez
12 | Diego Centelles
13 |
14 | BSD
15 |
16 | rospy
17 | std_msgs
18 | nav_msgs
19 | geometry_msgs
20 | sensor_msgs
21 | tf
22 | tf_conversions
23 |
24 |
25 | rospy
26 | std_msgs
27 | nav_msgs
28 | geometry_msgs
29 | sensor_msgs
30 | tf
31 | tf_conversions
32 |
33 |
34 | catkin
35 |
36 |
37 |
--------------------------------------------------------------------------------
/underwater_vehicle_dynamics/src/keyboard.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from std_msgs.msg import Float64MultiArray
4 | import termios, fcntl, sys, os
5 | import rospy
6 |
7 | #import services
8 | from std_srvs.srv import Empty
9 |
10 | if len(sys.argv) != 4:
11 | sys.exit("Usage: "+sys.argv[0]+" ")
12 |
13 |
14 | thrusters_topic=sys.argv[1]
15 |
16 | fd = sys.stdin.fileno()
17 | oldterm = termios.tcgetattr(fd)
18 | newattr = termios.tcgetattr(fd)
19 | newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
20 | termios.tcsetattr(fd, termios.TCSANOW, newattr)
21 |
22 | oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
23 | fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
24 |
25 | pub = rospy.Publisher(thrusters_topic, Float64MultiArray)
26 | rospy.init_node('keyboard')
27 | rospy.wait_for_service('/dynamics/reset')
28 | reset=rospy.ServiceProxy('/dynamics/reset', Empty)
29 | try:
30 | while not rospy.is_shutdown():
31 | thrusters=[0,0,0,0,0]
32 | msg = Float64MultiArray()
33 | try:
34 | c = sys.stdin.read(1)
35 | ##print "Got character", repr(c)
36 | if c=='w':
37 | thrusters[0]=thrusters[1]=0.4
38 | elif c=='s':
39 | thrusters[0]=thrusters[1]=-0.4
40 | elif c=='a':
41 | thrusters[4]=0.4
42 | elif c=='d':
43 | thrusters[4]=-0.4
44 | elif c==' ':
45 | reset()
46 | elif c=='\x1b':
47 | c2= sys.stdin.read(1)
48 | c2= sys.stdin.read(1)
49 | if c2=='A':
50 | thrusters[2]=thrusters[3]=0.4
51 | elif c2=='B':
52 | thrusters[2]=thrusters[3]=-0.4
53 | elif c2=='C':
54 | thrusters[0]=-0.4
55 | thrusters[1]=0.4
56 | elif c2=='D':
57 | thrusters[0]=0.4
58 | thrusters[1]=-0.4
59 | else:
60 | print 'wrong key pressed'
61 | while c!='':
62 | c = sys.stdin.read(1)
63 | except IOError: pass
64 | msg.data = thrusters
65 | pub.publish(msg)
66 | rospy.sleep(0.1)
67 | finally:
68 | termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
69 | fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
70 |
--------------------------------------------------------------------------------
/uwsim/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Changelog for package uwsim
3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | 1.4.1 (2015-12-14)
6 | ------------------
7 | * Can use package:// to resolve ROS package location for meshes
8 | * Can use package:// to pull a urdf from a ROS package
9 | * Fixed transform publishing to fit the new robotpublisher interface
10 | * Contributors: Bence Magyar, perezsolerj
11 |
12 | 1.4.0 (2015-09-23)
13 | ------------------
14 | * Initial support for markers and interactive markers issue #1
15 | * MultibeamSensors now use multiple cameras when the FOV is high in order to avoid eyefish distortions and allow FOV >180º.
16 | * Added xacro support for scene building, some xacro macros created as example
17 | * Added lightRate configuration option, shader projection is no longer affected by lighting
18 | * Support for buried objects and dredging
19 | * Added ARMask to Augmented reality elements such as trails, axis, rangeSensor debug, pointclouds and multibeamSensor debug so they are not showed on virtual cameras
20 | * Added debug visible tag to multibeam sensors (similar to range sensor)
21 | * Added gaussian random noise to camera output through shaders
22 | * Underwater particles are no longer present on multibeamSensor, although it can be activated through XML
23 | * Added ROSPointCloudLoader interface that allows to visualize 3D pointclouds on demand.
24 | * Major update on shader management:
25 | * added timeWindow and restarter (y key) to trajectory trail.
26 | * Bugs and fixes.
27 | * Contributors: David Fornas, Miguel Ribeiro, perezsolerj
28 |
--------------------------------------------------------------------------------
/uwsim/cmake/Modules/CheckGeographicLibDatasets.cmake:
--------------------------------------------------------------------------------
1 | ##
2 | # This module verifies the installation of the GeographicLib datasets and warns
3 | # if it doesn't detect them.
4 | ##
5 |
6 | find_path(GEOGRAPHICLIB_GEOID_PATH NAMES geoids PATH_SUFFIXES share/GeographicLib share/geographiclib)
7 | find_path(GEOGRAPHICLIB_GRAVITY_PATH_ NAMES gravity PATH_SUFFIXES share/GeographicLib)
8 | find_path(GEOGRAPHICLIB_MAGNETIC_PATH_ NAMES magnetic PATH_SUFFIXES share/GeographicLib)
9 |
10 | if(NOT GEOGRAPHICLIB_GEOID_PATH)
11 | message(STATUS "No geoid model datasets found. This will result on a SIGINT! Please execute the script install_geographiclib_dataset.sh in /mavros/scripts")
12 | else()
13 | message(STATUS "Geoid model datasets found in: " ${GEOGRAPHICLIB_GEOID_PATH}/geoid)
14 | set(GEOGRAPHICLIB_GEOID_PATH ${GEOGRAPHICLIB_GEOID_PATH}/geoid)
15 | endif()
16 | if(NOT GEOGRAPHICLIB_GRAVITY_PATH_)
17 | message(STATUS "No gravity field model datasets found. Please execute the script install_geographiclib_dataset.sh in /mavros/scripts")
18 | else()
19 | message(STATUS "Gravity Field model datasets found in: " ${GEOGRAPHICLIB_GRAVITY_PATH_}/gravity)
20 | set(GEOGRAPHICLIB_GRAVITY_PATH ${GEOGRAPHICLIB_GRAVITY_PATH_}/gravity)
21 | endif()
22 | if(NOT GEOGRAPHICLIB_MAGNETIC_PATH_)
23 | message(STATUS "No magnetic field model datasets found. Please execute the script install_geographiclib_dataset.sh in /mavros/scripts")
24 | else()
25 | message(STATUS "Magnetic Field model datasets found in: " ${GEOGRAPHICLIB_MAGNETIC_PATH_}/magnetic)
26 | set(GEOGRAPHICLIB_MAGNETIC_PATH ${GEOGRAPHICLIB_MAGNETIC_PATH_}/magnetic)
27 | endif()
28 |
--------------------------------------------------------------------------------
/uwsim/cmake/Modules/FindGeographicLib.cmake:
--------------------------------------------------------------------------------
1 | # Look for GeographicLib
2 | #
3 | # Set
4 | # GEOGRAPHICLIB_FOUND = TRUE
5 | # GeographicLib_INCLUDE_DIRS = /usr/local/include
6 | # GeographicLib_LIBRARIES = /usr/local/lib/libGeographic.so
7 | # GeographicLib_LIBRARY_DIRS = /usr/local/lib
8 |
9 | find_path (GeographicLib_INCLUDE_DIRS NAMES GeographicLib/Config.h)
10 |
11 | find_library (GeographicLib_LIBRARIES NAMES Geographic)
12 |
13 | include (FindPackageHandleStandardArgs)
14 | find_package_handle_standard_args (GeographicLib DEFAULT_MSG
15 | GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS)
16 | mark_as_advanced (GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS)
17 |
18 | #message(WARNING "GL: F:${GeographicLib_FOUND} L:${GeographicLib_LIBRARIES} I:${GeographicLib_INCLUDE_DIRS}")
19 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "browse": {
5 | "databaseFilename": "",
6 | "limitSymbolsToIncludedHeaders": true
7 | },
8 | "includePath": [
9 | "/home/irs/programming/uwsim_ws/devel/include",
10 | "/home/irs/programming/uwsim_deps_ws/install_isolated/include",
11 | "/opt/ros/melodic/include",
12 | "/home/irs/programming/uwsim_ws/src/dccomms_ros_pkgs/dccomms_ros_msgs/include",
13 | "/home/irs/programming/uwsim_ws/src/underwater_simulation/uwsim/include",
14 | "/usr/include"
15 | ],
16 | "name": "Linux",
17 | "intelliSenseMode": "gcc-x64"
18 | }
19 | ],
20 | "version": 4
21 | }
--------------------------------------------------------------------------------
/uwsim/data/scenes/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.autoComplete.extraPaths": [
3 | "/home/irs/programming/uwsim_ws/devel/lib/python2.7/dist-packages",
4 | "/opt/ros/melodic/lib/python2.7/dist-packages"
5 | ]
6 | }
--------------------------------------------------------------------------------
/uwsim/data/scenes/deviceLibrary.xacro:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/g500ARM5-rviz.urdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/g500ARM5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.04
8 | 0.04
9 | 12
10 | 1000
11 | 0.35
12 | 1e-7
13 | 0
14 | 2.5
15 | 2.2
16 | 0
17 |
18 | 0.1
19 |
20 | 0
21 | 0.05
22 | 0.3
23 |
24 |
25 |
26 |
27 | 0
28 | 640
29 | 480
30 |
31 |
32 |
33 | 0
34 | girona500/base_link
35 | 60
36 | 1.33
37 | 1
38 | 10000
39 |
40 | 0
41 | 2.5
42 | 0
43 |
44 |
45 | 0
46 | 0
47 | 0
48 |
49 |
50 |
51 |
52 | girona500
53 | data/scenes/g500ARM5.urdf
54 |
55 | 0
56 | 0.7
57 | 1.57
58 | 0
59 | 0
60 |
61 |
62 | 0
63 | 0
64 | -3.5
65 |
66 |
67 | 3.1415
68 | 0
69 | 0
70 |
71 |
72 | bowtech
73 | base_link
74 | 160
75 | 120
76 |
77 | -0.5
78 | 1
79 | -0.2
80 |
81 |
82 |
83 |
84 |
85 |
86 | /uwsim/joint_state
87 | girona500
88 |
89 |
90 | /uwsim/joint_state_command
91 | girona500
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/g500ARM5_laser.urdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/installScene:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | scriptDir=`dirname $0`
4 | server="http://www.irs.uji.es/uwsim/files"
5 | force="-k"
6 | metaScene=false
7 | clean=false
8 |
9 | while [[ $# > 0 ]]
10 | do
11 | key="$1"
12 |
13 | case $key in
14 | -f|--force)
15 | force="--overwrite"
16 | ;;
17 |
18 | -s|--scene)
19 | metaScene=true
20 | ;;
21 |
22 | -c|--clean)
23 | clean=true
24 | ;;
25 |
26 | *)
27 | filename=$1 # unknown option
28 | ;;
29 | esac
30 | shift # past argument or value
31 | done
32 |
33 | if [ "$metaScene" = true ]
34 | then
35 | wget $server/scenes/metaScenes/$filename -O ./scene.uws
36 | filename="./scene.uws"
37 | else
38 | if [ ! -f $filename ]
39 | then
40 | echo "Can't find $filename file"
41 | exit
42 | fi
43 | fi
44 |
45 | if [ ! -f $scriptDir/UWSimScene.dtd ]
46 | then
47 | echo "Directory where installScene is doesn't seem a UWSim scenes folder (UWSimScene.dtd does not exist)."
48 | exit
49 | fi
50 |
51 | if [ -d $HOME/.uwsim/data ]
52 | then
53 | echo "Installing..."
54 | while read -r line
55 | do
56 | words=( $line )
57 | location="${words[1]/#\~/$HOME}" #This expands "~" safely.
58 | if [[ "$location" = /* ]] ##Checks if it is an absolute path (we consider relative paths to be in the scriptDir)
59 | then
60 | wget $server/scenes/${words[0]} -O ~/.uwsim/downloaded_scene_data.tgz && tar -zxf ~/.uwsim/downloaded_scene_data.tgz $force -C $location
61 | mkdir -p $scriptDir/$location
62 | else
63 | wget $server/scenes/${words[0]} -O ~/.uwsim/downloaded_scene_data.tgz && tar -zxf ~/.uwsim/downloaded_scene_data.tgz $force -C $scriptDir/$location
64 | mkdir -p $scriptDir/$location/launch
65 | fi
66 | rm ~/.uwsim/downloaded_scene_data.tgz
67 | done < "$filename"
68 |
69 | else
70 | echo "Data directory doesn't exist. Run UWSim for the first time to download basic scene data."
71 | exit
72 | fi
73 |
74 | if [ "$metaScene" = true ] || [ "$clean" = true ]
75 | then
76 | rm "$filename"
77 | fi
78 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/launch/.gitignore:
--------------------------------------------------------------------------------
1 | !.gitignore
2 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/launch/cuba_aruco.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/launch/demo-hil.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/launch/demo-sitl.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/launch/netsim_cirs.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/objectLibrary.xacro:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/shapesTest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.04
8 | 0.04
9 | 12
10 | 1000
11 | 0.35
12 | 1e-7
13 | 0
14 | 2.5
15 | 2.2
16 | 0
17 |
18 | 0.1
19 |
20 | 0
21 | 0.05
22 | 0.3
23 |
24 |
25 |
26 |
27 | 0
28 | 640
29 | 480
30 |
31 |
32 |
33 | 0
34 | r2d2
35 | 60
36 | 1.33
37 | 1
38 | 10000
39 |
40 | 0
41 | 0
42 | 2
43 |
44 |
45 | 1.57
46 | 0
47 | 0
48 |
49 |
50 |
51 |
52 |
53 | r2d2
54 | data/scenes/r2d2.urdf
55 |
56 | 0
57 | 0
58 | -3.5
59 |
60 |
61 | 1.57
62 | 0
63 | 0
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/ship.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.04
8 | 0.04
9 | 12
10 | 1000
11 | 0.35
12 | 1e-7
13 | 0
14 | 2.5
15 | 2.2
16 | 0
17 |
18 | 0.1
19 |
20 | 0
21 | 0.05
22 | 0.3
23 |
24 |
25 |
26 | 0.0
27 | 0.05
28 | 0.3
29 |
30 |
31 | 0.015
32 | 0.0075
33 | 0.005
34 |
35 |
36 |
37 | 0
38 | 640
39 | 480
40 |
41 |
42 | 0
43 | ship
44 | 60
45 | 1.33
46 | 1
47 | 10000
48 |
49 | 25
50 | -25
51 | 25
52 |
53 |
54 | 0
55 | 0
56 | 0
57 |
58 |
59 |
60 |
61 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/ship_scene.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.04
8 | 0.04
9 | 12
10 | 1000
11 | 0.35
12 | 1e-7
13 | 0
14 | 2.5
15 | 2.2
16 | 0
17 |
18 | 0.1
19 |
20 | 0
21 | 0.05
22 | 0.3
23 |
24 |
25 |
26 | 0.0
27 | 0.05
28 | 0.3
29 |
30 |
31 | 0.015
32 | 0.0075
33 | 0.005
34 |
35 |
36 |
37 | 0
38 | 640
39 | 480
40 |
41 |
42 | 0
43 | ship
44 | 60
45 | 1.33
46 | 1
47 | 10000
48 |
49 | 25
50 | -25
51 | 25
52 |
53 |
54 | 0
55 | 0
56 | 0
57 |
58 |
59 |
60 |
61 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/shipwreck.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 1.0
8 | 1.0
9 | 12
10 | 10000
11 | 0.35
12 | 1e-8
13 | 0
14 | -2.5
15 | 2.2
16 | 0
17 |
18 | 0.1
19 |
20 | 0.017
21 | 0.027
22 | 0.079
23 |
24 |
25 |
26 | 0.017
27 | 0.027
28 | 0.079
29 |
30 |
31 | 0.015
32 | 0.0075
33 | 0.005
34 |
35 |
36 |
37 |
38 | 0
39 | 800
40 | 600
41 |
42 |
43 |
44 | 1
45 | girona500_RAUVI/base_link
46 | 60
47 | 1.33
48 | 1
49 | 10000
50 |
51 | 16
52 | 9
53 | -7
54 |
55 |
56 | 5
57 | 7
58 | -10
59 |
60 |
61 |
62 |
63 | girona500_RAUVI
64 | data/scenes/g500ARM5.urdf
65 |
66 | 0
67 | M_PI_4
68 | M_PI_4
69 | 0
70 | -0.3
71 |
72 |
73 | 5
74 | 7
75 | -10
76 |
77 |
78 | 3.1415
79 | 0
80 | 0
81 |
82 |
83 |
84 |
85 | girona500_TRIDENT
86 | data/scenes/g500ARM5.urdf
87 |
88 | 0
89 | M_PI_4
90 | M_PI_4
91 | 0
92 | -0.3
93 |
94 |
95 | 7
96 | 5
97 | -11
98 |
99 |
100 | 3.1415
101 | 0
102 | 1.57
103 |
104 |
105 |
106 |
124 |
125 |
126 |
127 | /dataNavigator_G500RAUVI
128 | girona500_RAUVI
129 |
130 |
131 | /dataNavigator_G500TRIDENT
132 | girona500_TRIDENT
133 |
134 |
135 | /uwsim/girona500_odom_RAUVI
136 | girona500_RAUVI
137 |
138 |
139 | /uwsim/girona500_odom_TRIDENT
140 | girona500_TRIDENT
141 |
142 |
143 | world
144 | 0
145 | 10
146 |
147 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/ujione-rviz.urdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/ujione.urdf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/ujione.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | 0.04
8 | 0.04
9 | 12
10 | 1000
11 | 0.35
12 | 1e-7
13 | 0
14 | 2.5
15 | 2.2
16 | 0
17 |
18 | 0.1
19 |
20 | 0
21 | 0.05
22 | 0.3
23 |
24 |
25 |
26 |
27 | 0
28 | 640
29 | 480
30 |
31 |
32 |
33 | 0
34 | ujione/ujione_jaw_inner
35 | 60
36 | 1.33
37 | 0.05
38 | 10000
39 |
40 | 0
41 | 1.5
42 | 0
43 |
44 |
45 | 0
46 | 0
47 | 0
48 |
49 |
50 |
51 |
52 | ujione
53 | data/scenes/ujione.urdf
54 |
55 | -0.4
56 |
57 |
58 | 0
59 | 0
60 | -3.5
61 |
62 |
63 | 0
64 | 0
65 | 0
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/vehicleLibrary.xacro:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/uwsim/data/scenes/xacroExample.xml.xacro:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 0
20 | 0
21 | 2.2
22 | 0
23 | 0.3
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/uwsim/data/shaders/default_scene.vert:
--------------------------------------------------------------------------------
1 | // osgOcean Uniforms
2 | // -----------------
3 | uniform mat4 osg_ViewMatrixInverse;
4 | uniform float osgOcean_WaterHeight;
5 | uniform vec3 osgOcean_Eye;
6 | uniform vec3 osgOcean_UnderwaterAttenuation;
7 | uniform vec4 osgOcean_UnderwaterDiffuse;
8 | uniform bool osgOcean_EnableUnderwaterScattering;
9 | // -----------------
10 |
11 | varying vec3 vExtinction;
12 | varying vec3 vInScattering;
13 |
14 | varying vec3 vNormal;
15 | varying vec3 vLightDir;
16 | varying vec3 vEyeVec;
17 | varying float vWorldHeight;
18 | varying vec4 color;
19 |
20 | //Laser variables
21 | // -----------------
22 | uniform mat4 LightModelViewProjectionMatrix;
23 |
24 | varying vec4 ShadowCoord;
25 | varying vec4 textureCoord;
26 | // -----------------
27 |
28 | void computeScattering( in vec3 eye, in vec3 worldVertex, out vec3 extinction, out vec3 inScattering )
29 | {
30 | float viewDist = length(eye-worldVertex);
31 |
32 | float depth = max(osgOcean_WaterHeight-worldVertex.z, 0.0);
33 |
34 | extinction = exp(-osgOcean_UnderwaterAttenuation*viewDist*2.0);
35 |
36 | // Need to compute accurate kd constant.
37 | // const vec3 kd = vec3(0.001, 0.001, 0.001);
38 | inScattering = osgOcean_UnderwaterDiffuse.rgb * (1.0-extinction*exp(-depth*vec3(0.001)));
39 | }
40 |
41 | void main(void)
42 | {
43 | gl_TexCoord[0] = gl_MultiTexCoord0;
44 | gl_Position = ftransform();
45 | gl_FogFragCoord = gl_Position.z;
46 | gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex; // for reflections
47 |
48 | vNormal = gl_NormalMatrix * gl_Normal;
49 | vLightDir = gl_LightSource[osgOcean_LightID].position.xyz;
50 | vEyeVec = -vec3(gl_ModelViewMatrix*gl_Vertex);
51 |
52 | vec4 worldVertex = (osg_ViewMatrixInverse*gl_ModelViewMatrix) * gl_Vertex;
53 |
54 | //Laser computations
55 | ShadowCoord = LightModelViewProjectionMatrix*worldVertex;
56 | // -----------------
57 |
58 | if (osgOcean_EnableUnderwaterScattering)
59 | computeScattering( osgOcean_Eye, worldVertex.xyz, vExtinction, vInScattering);
60 |
61 |
62 | vWorldHeight = worldVertex.z;
63 | color=gl_FrontMaterial.diffuse;
64 | }
65 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/AcousticCommsChannel.h:
--------------------------------------------------------------------------------
1 | #ifndef UWSIM_ACOUSTICCOMMSCHANNEL_
2 | #define UWSIM_ACOUSTICCOMMSCHANNEL_
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace uwsim {
9 |
10 | class AcousticCommsChannel {
11 | public:
12 | AcousticCommsChannelConfig config;
13 | AcousticCommsChannel(AcousticCommsChannelConfig cfg);
14 | private:
15 | bool _AddToNetSim();
16 |
17 | };
18 | }
19 | #endif
20 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/AcousticCommsDevice.h:
--------------------------------------------------------------------------------
1 | #ifndef AcousticCommsDevice_ECHO_H_
2 | #define AcousticCommsDevice_ECHO_H_
3 | #include "ConfigXMLParser.h"
4 | #include "ROSInterface.h"
5 | #include "SimulatedDevice.h"
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | using namespace uwsim;
15 |
16 | class AcousticCommsDevice_Config : public CommsDevice_Config {
17 |
18 | public:
19 | // XML members
20 | double range, pT, frequency, L, K, turnOnEnergy, turnOffEnergy, preamble,
21 | pTConsume, pRConsume, pIdle, codingEff, bitErrorRate, energyLevel;
22 | uint32_t symbolsPerSecond;
23 | // constructor
24 | AcousticCommsDevice_Config(std::string type_)
25 | : CommsDevice_Config(type_), range(100), pT(0.2818), frequency(25),
26 | L(0.0), K(2.0), turnOnEnergy(0.0), turnOffEnergy(0.0), preamble(0.0),
27 | pTConsume(0.660), pRConsume(0.395), pIdle(0.0) {}
28 | };
29 |
30 | class AcousticCommsDevice : public UWSimCommsDevice {
31 | public:
32 | AcousticCommsDevice_Config *config;
33 | AcousticCommsDevice(AcousticCommsDevice_Config *cfg,
34 | osg::ref_ptr target, SimulatedIAUV *auv);
35 | void AddToNetSim();
36 | static uint32_t nDevsReady;
37 | static uint32_t nDevs;
38 | void SetConfig(CommsDevice_Config *cfg);
39 | CommsDevice_Config *GetConfig();
40 |
41 | protected:
42 | bool _AddToNetSim();
43 |
44 | private:
45 | ros::ServiceClient _addService, _linkToChannelService;
46 | };
47 |
48 | /* You will need to add your code HERE */
49 | class AcousticCommsDevice_Factory : public CommsDevice_Factory {
50 | public:
51 | // this is the only place the device/interface type is set
52 | AcousticCommsDevice_Factory(std::string type_ = "AcousticCommsDevice")
53 | : CommsDevice_Factory(type_){};
54 | UWSimCommsDevice *Create(CommsDevice_Config *cfg,
55 | osg::ref_ptr target, SimulatedIAUV *auv);
56 | SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node *node,
57 | ConfigFile *config);
58 | };
59 |
60 | class AcousticCommsDevice_ROSPublisher : public CommsDevice_ROSPublisher {
61 | public:
62 | AcousticCommsDevice_ROSPublisher(AcousticCommsDevice *dev, std::string topic,
63 | int rate)
64 | : CommsDevice_ROSPublisher(dev, topic, rate) {}
65 |
66 | ~AcousticCommsDevice_ROSPublisher() {}
67 | };
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/BulletPhysics.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef BULLETPHYSICS_H_
14 | #define BULLETPHYSICS_H_
15 |
16 | #include "SimulatorConfig.h"
17 | #include "UWSimUtils.h"
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | #include
27 |
28 | //#include
29 |
30 | #define UWSIM_DEFAULT_GRAVITY btVector3(0,0,-1)
31 |
32 | // Define filter groups
33 | enum CollisionTypes
34 | {
35 | COL_NOTHING = 0x00000000, COL_OBJECTS = 0x00000001, COL_VEHICLE = 0x00000010, COL_EVERYTHING = 0x11111111,
36 | };
37 |
38 | /*class NodeDataType : public osg::Referenced{
39 | public:
40 | NodeDataType(btRigidBody * rigidBody,int catcha){ catchable=catcha; rb=rigidBody;};
41 | int catchable;
42 | btRigidBody * rb;
43 |
44 | };*/
45 |
46 | class CollisionDataType : public osg::Referenced
47 | {
48 | public:
49 | CollisionDataType(std::string nam, std::string vehName, int isVehi)
50 | {
51 | vehicleName = vehName;
52 | name = nam;
53 | isVehicle = isVehi;
54 | }
55 | ;
56 | std::string getObjectName()
57 | {
58 | if (isVehicle)
59 | return vehicleName;
60 | else
61 | return name;
62 | }
63 | ;
64 | std::string name, vehicleName;
65 | int isVehicle;
66 |
67 | };
68 |
69 | //Adds tick callback manager which will do all stuff needed in pretick callback
70 | void preTickCallback(btDynamicsWorld *world, btScalar timeStep);
71 |
72 | //Adds tick callback manager which will do all stuff needed in posttick callback
73 | void postTickCallback(btDynamicsWorld *world, btScalar timeStep);
74 |
75 | class BulletPhysics : public osg::Referenced
76 | {
77 |
78 | public:
79 | typedef enum
80 | {
81 | SHAPE_BOX, SHAPE_SPHERE, SHAPE_TRIMESH, SHAPE_COMPOUND_TRIMESH, SHAPE_COMPOUND_BOX, SHAPE_COMPOUND_CYLINDER
82 | } collisionShapeType_t;
83 |
84 | btDiscreteDynamicsWorld * dynamicsWorld;
85 | //osgbCollision::GLDebugDrawer debugDrawer;
86 |
87 | BulletPhysics(PhysicsConfig physicsConfig, osgOcean::OceanTechnique* oceanSurf);
88 |
89 | void setGravity(btVector3 g)
90 | {
91 | dynamicsWorld->setGravity(g);
92 | }
93 | btRigidBody* addObject(osg::MatrixTransform *root, osg::Node *node, CollisionDataType * data,
94 | std::shared_ptr pp, osg::Node * colShape = NULL);
95 |
96 | void stepSimulation(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep);
97 | void printManifolds();
98 |
99 | int getNumCollisions();
100 |
101 | btRigidBody* copyObject(btRigidBody * copied);
102 | int physicsStep;
103 |
104 | btPersistentManifold * getCollision(int i);
105 |
106 | ~BulletPhysics()
107 | {
108 | }
109 | ;
110 |
111 | //This class stores information related to different sources that need to be called in internal tick callbacks.
112 | //To know force sensors.
113 | class TickCallbackManager
114 | {
115 | private:
116 | //Force sensor structures;
117 | struct ForceSensorcbInfo
118 | {
119 | btRigidBody * copy, * target;
120 | btVector3 linInitial, angInitial,linFinal, angFinal;
121 | };
122 | std::vector forceSensors;
123 |
124 | void preTickForceSensors();
125 | void postTickForceSensors();
126 | public:
127 |
128 | int substep; //Tracks number of substep;
129 |
130 | TickCallbackManager(){};
131 | int addForceSensor(btRigidBody * copy, btRigidBody * target);
132 | void getForceSensorSpeed(int forceSensor, double linSpeed[3],double angSpeed[3]);
133 | void physicsInternalPreProcessCallback(btScalar timeStep);
134 | void physicsInternalPostProcessCallback(btScalar timeStep);
135 | };
136 |
137 |
138 | TickCallbackManager * callbackManager;
139 |
140 | private:
141 | btDefaultCollisionConfiguration * collisionConfiguration;
142 | btCollisionDispatcher * dispatcher;
143 | btConstraintSolver * solver;
144 | btBroadphaseInterface * inter;
145 |
146 | osgOcean::OceanTechnique* oceanSurface;
147 |
148 | void cleanManifolds();
149 | btCollisionShape* GetCSFromOSG(osg::Node * node, collisionShapeType_t ctype);
150 |
151 | };
152 |
153 |
154 | #endif
155 |
156 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/CommsDevice.h:
--------------------------------------------------------------------------------
1 | #ifndef CommsDevice_ECHO_H_
2 | #define CommsDevice_ECHO_H_
3 | #include "ConfigXMLParser.h"
4 | #include "ROSInterface.h"
5 | #include "SimulatedDevice.h"
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | using namespace uwsim;
13 |
14 | class CommsDevice_Config : public SimulatedDeviceConfig {
15 |
16 | public:
17 | // XML members
18 | std::string relativeTo, tfId, relativeTfId, dccommsId, logLevel;
19 | PacketBuilderConfig txPacketBuilderConfig, rxPacketBuilderConfig;
20 | unsigned int mac, channelId, txFifoSize, maxBackoffSlots;
21 | double position[3]{0, 0, 0}, orientation[3]{0, 0, 0};
22 | Mesh mesh;
23 | int disable = 0;
24 | std::string macProtocol;
25 | double macDistance;
26 |
27 | CommsDevice_Config(std::string type_) : SimulatedDeviceConfig(type_) {}
28 | };
29 |
30 | class UWSimCommsDevice : public SimulatedDevice {
31 | public:
32 | osg::Node *parent;
33 | SimulatedIAUV *auv;
34 | osg::ref_ptr target;
35 | ros::NodeHandle node;
36 | std::string targetTfId, tfId;
37 | bool render;
38 | dccomms::PacketBuilderPtr txPacketBuilder, rxPacketBuilder;
39 |
40 | UWSimCommsDevice(CommsDevice_Config *cfg, osg::ref_ptr target,
41 | SimulatedIAUV *auv);
42 |
43 | void Init(CommsDevice_Config *cfg, osg::ref_ptr target,
44 | SimulatedIAUV *auv);
45 |
46 | void AddToNetSim();
47 | virtual CommsDevice_Config *GetConfig() = 0;
48 | virtual void SetConfig(CommsDevice_Config *cfg) = 0;
49 | void SetPacketBuilder(PACKET_TYPE pType, CommsDevice_Config *cfg,
50 | PacketBuilderConfig *pbcfg);
51 |
52 | protected:
53 | virtual bool _AddToNetSim() = 0;
54 |
55 | private:
56 | ros::ServiceClient _checkService, _rmService;
57 | bool _Check();
58 | bool _Remove();
59 | };
60 |
61 | /* You will need to add your code HERE */
62 | class CommsDevice_Factory : public SimulatedDeviceFactory {
63 | public:
64 | // this is the only place the device/interface type is set
65 | CommsDevice_Factory(std::string type_ = "CommsDevice")
66 | : SimulatedDeviceFactory(type_){};
67 | virtual UWSimCommsDevice *Create(CommsDevice_Config *cfg,
68 | osg::ref_ptr target,
69 | SimulatedIAUV *auv) = 0;
70 |
71 | virtual void processCommonConfig(const xmlpp::Node *node, ConfigFile *config,
72 | CommsDevice_Config *commonConfig);
73 |
74 | // Methods from SimulatedDevice
75 | virtual bool applyConfig(SimulatedIAUV *auv, Vehicle &vehicleChars,
76 | SceneBuilder *sceneBuilder, size_t iteration);
77 | virtual std::vector>
78 | getInterface(ROSInterfaceInfo &rosInterface,
79 | std::vector> &iauvFile);
80 | virtual SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node *node,
81 | ConfigFile *config) = 0;
82 | };
83 |
84 | class CommsDevice_ROSPublisher : public ROSPublisherInterface {
85 | public:
86 | CommsDevice_ROSPublisher(UWSimCommsDevice *dev, std::string topic, int rate)
87 | : ROSPublisherInterface(topic, rate), dev(dev) {}
88 |
89 | UWSimCommsDevice *dev;
90 | virtual void createPublisher(ros::NodeHandle &nh);
91 | virtual void publish();
92 |
93 | ~CommsDevice_ROSPublisher() {}
94 |
95 | private:
96 | tf::TransformBroadcaster _tfBr;
97 | };
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/CustomCommsChannel.h:
--------------------------------------------------------------------------------
1 | #ifndef UWSIM_CUSTOMCOMMSCHANNEL_
2 | #define UWSIM_CUSTOMCOMMSCHANNEL_
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace uwsim {
9 |
10 | class CustomCommsChannel {
11 | public:
12 | CustomCommsChannelConfig config;
13 | CustomCommsChannel(CustomCommsChannelConfig cfg);
14 | private:
15 | bool _AddToNetSim();
16 |
17 | };
18 | }
19 | #endif
20 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/CustomCommsDevice.h:
--------------------------------------------------------------------------------
1 | #ifndef CustomCommsDevice_ECHO_H_
2 | #define CustomCommsDevice_ECHO_H_
3 | #include "ConfigXMLParser.h"
4 | #include "ROSInterface.h"
5 | #include "SimulatedDevice.h"
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | using namespace uwsim;
16 |
17 | class CustomCommsDevice_Config : public CommsDevice_Config {
18 |
19 | public:
20 | // XML members
21 | unsigned int txChannelId, rxChannelId;
22 | double bitrate;
23 | double txJitter, rxJitter;
24 | double intrinsicDelay;
25 | double maxDistance, minDistance;
26 | double pktErrRatioIncPerMeter, minPktErrRatio;
27 | std::string errorRateExpr, errorUnit;
28 |
29 | // constructor
30 | CustomCommsDevice_Config(std::string type_) : CommsDevice_Config(type_) {}
31 | };
32 |
33 | class CustomCommsDevice : public UWSimCommsDevice {
34 | public:
35 | CustomCommsDevice_Config *config;
36 | CustomCommsDevice(CustomCommsDevice_Config *cfg,
37 | osg::ref_ptr target, SimulatedIAUV *auv);
38 | void AddToNetSim();
39 | static uint32_t nDevsReady;
40 | static uint32_t nDevs;
41 | void SetConfig(CommsDevice_Config *cfg);
42 | CommsDevice_Config *GetConfig();
43 |
44 | protected:
45 | bool _AddToNetSim();
46 |
47 | private:
48 | ros::ServiceClient _addService, _linkToChannelService;
49 | };
50 |
51 | /* You will need to add your code HERE */
52 | class CustomCommsDevice_Factory : public CommsDevice_Factory {
53 | public:
54 | // this is the only place the device/interface type is set
55 | CustomCommsDevice_Factory(std::string type_ = "CustomCommsDevice")
56 | : CommsDevice_Factory(type_){};
57 | UWSimCommsDevice *Create(CommsDevice_Config *cfg,
58 | osg::ref_ptr target, SimulatedIAUV *auv);
59 | SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node *node,
60 | ConfigFile *config);
61 | };
62 |
63 | class CustomCommsDevice_ROSPublisher : public CommsDevice_ROSPublisher {
64 | public:
65 | CustomCommsDevice_ROSPublisher(CustomCommsDevice *dev, std::string topic,
66 | int rate)
67 | : CommsDevice_ROSPublisher(dev, topic, rate) {}
68 |
69 | ~CustomCommsDevice_ROSPublisher() {}
70 | };
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/CustomWidget.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef CUSTOMWIDGET
14 | #define CUSTOMWIDGET
15 |
16 | #include "SimulatorConfig.h"
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | class CustomWidget
23 | {
24 | public:
25 | CustomWidget()
26 | {
27 | }
28 |
29 | virtual osg::ref_ptr getWidgetWindow()=0;
30 |
31 | ~CustomWidget()
32 | {
33 | }
34 | };
35 |
36 | #endif
37 |
38 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/DVLSensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef DVLSENSOR_H_
14 | #define DVLSENSOR_H_
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | class DVLSensor
27 | {
28 |
29 | public:
30 | std::string name,parentLinkName;
31 |
32 | /** Constructor
33 | * @param name the name of the dvl sensor
34 | * @param parentName the name of the link that holds the DVL sensor
35 | * @param parent the node of the scene graph that holds the sensor
36 | * @param rMl the sensor measures are given with respect to the root (r). Use rMl to transform them to another frame ('l' is the new frame, typically the localized world)
37 | * @param std the standard deviation on the sensor measures
38 | */
39 | DVLSensor(std::string sensor_name, std::string parentName, osg::Node *parent, osg::Matrixd rMl, double std = 0) :
40 | name(sensor_name) ,parentLinkName(parentName), parent_(parent), rMl_(rMl), std_(std)
41 | {
42 | node_ = new osg::Node();
43 | parent->asGroup()->addChild(node_);
44 | tprevious_ = ros::Time::now();
45 | }
46 |
47 | osg::Vec3d getMeasurement();
48 | int getTFTransform(tf::Pose & pose, std::string & parent);
49 |
50 | double getStandardDeviation()
51 | {
52 | return std_;
53 | }
54 |
55 | virtual ~DVLSensor()
56 | {
57 | }
58 |
59 | private:
60 | osg::ref_ptr parent_;
61 | osg::Matrixd rMl_;
62 | double std_;
63 | osg::ref_ptr node_;
64 | ros::Time tprevious_;
65 | osg::Vec3d xprevious_;
66 |
67 | boost::mt19937 rng_; ///< Boost random number generator
68 | };
69 |
70 | #endif /* DVLSENSOR_H_ */
71 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/DredgeTool.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 |
14 | #ifndef DREDGE_TOOL_H_
15 | #define DREDGE_TOOL_H_
16 | #include "SimulatedDevice.h"
17 | using namespace uwsim;
18 |
19 | //PARTICLE SYSTEM FUNCTIONS
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | //This operator attracts the particles to a sink (dredge tool).
29 | //This class could be in UWSimUtils as it is not specific for Dredge Tool, but I left it here because I think
30 | // it will not be used anywhere else
31 | class AttractOperator : public osgParticle::Operator
32 | {
33 | public:
34 | AttractOperator() : osgParticle::Operator(), _magnitude(1.0f), _killSink(true){}
35 | AttractOperator( const AttractOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY )
36 | : osgParticle::Operator(copy, copyop), _magnitude(copy._magnitude), _killSink(copy._killSink)
37 | {}
38 | META_Object( spin, AttractOperator );
39 |
40 | /// Set the acceleration scale
41 | void setMagnitude( float mag ) { _magnitude = mag; }
42 | /// Get the acceleration scale
43 | float getMagnitude() const { return _magnitude; }
44 | /// Set whether the attractor kills the particles once they arrive
45 | void setKillSink( bool kill ) { _killSink = kill; }
46 | /// Get whether the attractor kills the particles once they arrive
47 | bool getKillSink() const { return _killSink; }
48 | /// Apply attraction to a particle. Do not call this method manually.
49 | inline void operate( osgParticle::Particle* P, double dt );
50 |
51 | protected:
52 | virtual ~AttractOperator() {}
53 | AttractOperator& operator=( const AttractOperator& ) { return *this; }
54 | float _magnitude;
55 | bool _killSink;
56 | };
57 |
58 | //Creates a particle system
59 | osgParticle::ParticleSystem* createSmokeParticles( osg::Group* parent, osgParticle::RandomRateCounter * rrc);
60 |
61 |
62 | //Driver/ROSInterface configuration
63 | class DredgeTool_Config : public SimulatedDeviceConfig
64 | {
65 | public:
66 | //XML members
67 | std::string target;
68 | double offsetp[3];
69 | double offsetr[3];
70 | //constructor
71 | DredgeTool_Config(std::string type_) :
72 | SimulatedDeviceConfig(type_)
73 | {
74 | }
75 | };
76 |
77 | //Driver/ROSInterface factory class
78 | class DredgeTool_Factory : public SimulatedDeviceFactory
79 | {
80 | public:
81 | //this is the only place the device/interface type is set
82 | DredgeTool_Factory(std::string type_ = "DredgeTool") :
83 | SimulatedDeviceFactory(type_)
84 | {
85 | }
86 | ;
87 |
88 | SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node* node, ConfigFile * config);
89 | bool applyConfig(SimulatedIAUV * auv, Vehicle &vehicleChars, SceneBuilder *sceneBuilder, size_t iteration);
90 | };
91 |
92 | //can be a sparate header file for actual implementation classes...
93 |
94 | #include "ConfigXMLParser.h"
95 | #include "ROSInterface.h"
96 | #include
97 | #include "UWSimUtils.h"
98 |
99 | //Driver class
100 | class DredgeTool : public SimulatedDevice, public AbstractDredgeTool
101 | {
102 | osg::ref_ptr target;
103 | osgParticle::ParticleSystem* smoke;
104 | osgParticle::RandomRateCounter * rrc;
105 |
106 | //Number of particles in the system (this should decrease slowly)
107 | int particles;
108 |
109 | void applyPhysics(BulletPhysics * bulletPhysics)
110 | {
111 | }
112 | public:
113 | std::string info; //Device's property
114 |
115 | DredgeTool(DredgeTool_Config * cfg, osg::ref_ptr target);
116 |
117 | virtual std::shared_ptr getDredgePosition();
118 |
119 | void dredgedParticles(int nparticles);
120 |
121 |
122 | };
123 |
124 |
125 | #endif
126 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/ForceSensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef FORCESENSOR_H_
14 | #define FORCESENSOR_H_
15 | #include "SimulatedDevice.h"
16 | using namespace uwsim;
17 |
18 | class ForceSensor_Config : public SimulatedDeviceConfig
19 | {
20 | public:
21 | //XML members
22 | std::string target;
23 | double offsetp[3];
24 | double offsetr[3];
25 | //constructor
26 | ForceSensor_Config(std::string type_) :
27 | SimulatedDeviceConfig(type_)
28 | {
29 | }
30 | };
31 |
32 | //Driver/ROSInterface factory class
33 | class ForceSensor_Factory : public SimulatedDeviceFactory
34 | {
35 | public:
36 | //this is the only place the device/interface type is set
37 | ForceSensor_Factory(std::string type_ = "ForceSensor") :
38 | SimulatedDeviceFactory(type_)
39 | {
40 | }
41 | ;
42 |
43 | SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node* node, ConfigFile * config);
44 | bool applyConfig(SimulatedIAUV * auv, Vehicle &vehicleChars, SceneBuilder *sceneBuilder, size_t iteration);
45 | std::vector > getInterface(ROSInterfaceInfo & rosInterface,
46 | std::vector > & iauvFile);
47 | };
48 |
49 | //can be a sparate header file for actual implementation classes...
50 |
51 | #include "ConfigXMLParser.h"
52 | #include "ROSInterface.h"
53 | #include
54 | #include
55 | #include "BulletPhysics.h"
56 |
57 | //Driver class
58 |
59 | class ForceSensor : public SimulatedDevice
60 | {
61 | void applyPhysics(BulletPhysics * bulletPhysics);
62 | double lastTimeStep;
63 | int CBreference;
64 | public:
65 | BulletPhysics * physics;
66 | btRigidBody * copy, * btTarget; //Rigid object copy with physical reaction
67 | osg::ref_ptr target;
68 | double offsetp[3];
69 | osg::Matrixd offset; //We only need rotation as traslation goes to bullet directly
70 | int physicsApplied;
71 |
72 | ForceSensor(ForceSensor_Config * cfg, osg::ref_ptr target);
73 | void getForceTorque(double force[3], double torque[3]);
74 | };
75 |
76 |
77 |
78 | //ROS publishers and subscribers work exactly as before, no subclassing is needed
79 | class ForceSensor_ROSPublisher : public ROSPublisherInterface
80 | {
81 | //this is just an example, use a pointer to SimulatedIAUV, if only ROSInterface is implemented
82 | //pointer to a device
83 | ForceSensor * dev;
84 | public:
85 | ForceSensor_ROSPublisher(ForceSensor *dev, std::string topic, int rate) :
86 | ROSPublisherInterface(topic, rate), dev(dev)
87 | {
88 | }
89 |
90 | void createPublisher(ros::NodeHandle &nh);
91 | void publish();
92 |
93 | ~ForceSensor_ROSPublisher()
94 | {
95 | }
96 | };
97 |
98 | #endif
99 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/GPSSensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef GPSSENSOR_H_
14 | #define GPSSENSOR_H_
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 | #include "osgOceanScene.h"
23 | #include
24 |
25 | class GPSSensor
26 | {
27 |
28 | public:
29 | std::string name,parentLinkName;
30 |
31 | /** Constructor
32 | * @param name the name of the GPS sensor
33 | * @param parentName the name of the link that holds the GPS sensor
34 | * @param parent the node of the scene graph that holds the sensor
35 | * @param rMl the sensor measures are given with respect to the root (r). Use rMl to transform them to another frame ('l' is the new frame, typically the localized world)
36 | * @param std the standard deviation on the sensor measures
37 | */
38 | GPSSensor(osgOceanScene *oscene, std::string sensor_name, std::string parentName, osg::Node *parent, osg::Matrixd rMl, double std = 0) :
39 | name(sensor_name),parentLinkName(parentName), oscene_(oscene), parent_(parent), rMl_(rMl), std_(std)
40 | {
41 | node_ = new osg::Node();
42 | parent->asGroup()->addChild(node_);
43 | }
44 |
45 | osg::Vec3d getMeasurement();
46 | int getTFTransform(tf::Pose & pose, std::string & parent);
47 |
48 | double getStandardDeviation()
49 | {
50 | return std_;
51 | }
52 |
53 | /** Returns the depth of the sensor (in meters) under the water*/
54 | double depthBelowWater();
55 |
56 | virtual ~GPSSensor()
57 | {
58 | }
59 |
60 | private:
61 | osg::ref_ptr oscene_;
62 | osg::ref_ptr parent_;
63 | osg::Matrixd rMl_;
64 | double std_;
65 | osg::ref_ptr node_;
66 |
67 | boost::mt19937 rng_; ///< Boost random number generator
68 | };
69 |
70 | #endif /* GPSSENSOR_H_ */
71 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/HUDCamera.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef HUDCAMERA_H_
14 | #define HUDCAMERA_H_
15 |
16 | #include "SimulatorConfig.h"
17 | #include "CustomWidget.h"
18 |
19 | #include
20 |
21 | /** A ROS Camera subscriber that can be displayed as a widget */
22 | class HUDCamera : public CustomWidget
23 | {
24 | osg::ref_ptr widget;
25 |
26 | class widgetUpdateCallback : public osg::Drawable::UpdateCallback
27 | {
28 | osg::ref_ptr image;
29 | public:
30 | widgetUpdateCallback(osg::Image *i) :
31 | osg::Drawable::UpdateCallback()
32 | {
33 | this->image = i;
34 | }
35 | virtual void update(osg::NodeVisitor *nv, osg::Drawable *d)
36 | {
37 | (static_cast(d))->setImage(image, true, false);
38 | }
39 | };
40 |
41 | public:
42 | unsigned int width, height; ///< Width and height in pixels of the input image
43 | unsigned int posx, posy; ///< Default position of the widget, given in pixels wrt bottom-left corner (X to the right, Y upwards)
44 | double scale; ///< Percentage of default widget scaling (0..1)
45 |
46 | osg::ref_ptr osg_image; //The osg::Image object where to store the ROS image
47 | bool ready_; //true if images have been acquired
48 |
49 | /** Constructor from the image and info topics */
50 | HUDCamera(unsigned int width, unsigned int height, unsigned int posx = 0, unsigned int posy = 0, double scale = 1,
51 | int blackWhite = 0);
52 |
53 | bool ready()
54 | {
55 | return ready_;
56 | }
57 |
58 | //Interface to be implemented by widgets. Build a widget window with the data to be displayed
59 | osg::ref_ptr getWidgetWindow();
60 |
61 | ~HUDCamera();
62 | };
63 |
64 | #endif /* HUDCAMERA_H_ */
65 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/InertialMeasurementUnit.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef INERTIALMEASUREMENTUNIT_H_
14 | #define INERTIALMEASUREMENTUNIT_H_
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 | #include
23 |
24 | class InertialMeasurementUnit
25 | {
26 |
27 | public:
28 | std::string name,parentLinkName;
29 |
30 | /** Constructor
31 | * @param imu_name the name of the IMU
32 | * @param parentName the name of the link that holds the IMU
33 | * @param imu_parent the node of the scene graph that holds the imu
34 | * @param rMl the imu measures are given with respect to the root (r). Use rMl to transform them to another frame ('l' is the new frame, typically the localized world)
35 | * @param imu_std the standard deviation on the imu measures
36 | */
37 | InertialMeasurementUnit(std::string imu_name, std::string parentName, osg::Node *imu_parent, osg::Matrixd rMl, double imu_std = 0) :
38 | name(imu_name),parentLinkName(parentName), parent_(imu_parent), rMl_(rMl), std_(imu_std)
39 | {
40 | imu_node_ = new osg::Node();
41 | imu_parent->asGroup()->addChild(imu_node_);
42 | }
43 |
44 | int getTFTransform(tf::Pose & pose, std::string & parent);
45 | osg::Quat getMeasurement();
46 |
47 | double getStandardDeviation()
48 | {
49 | return std_;
50 | }
51 |
52 | virtual ~InertialMeasurementUnit()
53 | {
54 | }
55 |
56 | private:
57 | osg::ref_ptr parent_;
58 | osg::Matrixd rMl_;
59 | double std_;
60 | osg::ref_ptr imu_node_;
61 |
62 | boost::mt19937 rng_; ///< Boost random number generator
63 | };
64 |
65 | #endif /* INERTIALMEASUREMENTUNIT_H_ */
66 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/KinematicChain.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef KINEMATICCHAIN_H_
14 | #define KINEMATICCHAIN_H_
15 |
16 | #include "SimulatorConfig.h"
17 | #include
18 | #include
19 |
20 | #include
21 | #include
22 | #include "BulletPhysics.h"
23 |
24 | struct MimicArm
25 | {
26 | int joint;
27 | double offset, multiplier;
28 | int sliderCrank;
29 | };
30 |
31 | /** Abstract Kinematic Chain class for holding articulated 3D Models
32 | */
33 | class KinematicChain
34 | {
35 | public:
36 | std::vector > link; ///< pointers to link models
37 | std::vector q; ///< Joint values
38 | std::vector > limits; /// names; //Names of the joints
40 |
41 | std::vector mimic; //Mimic joints info
42 | std::vector jointType; //type of joints 0 fixed, 1 rotation, 2 prismatic
43 | std::vector > joints; ///< pointers to transforms between links
44 | std::vector > zerojoints; /// baseTransform; /// tool; ///< Pointer to the tool osg node
49 |
50 | std::vector qLastSafe; ///< Last joint values not colliding
51 | BulletPhysics * physics; /// Bullet physics pointer to query
52 |
53 | ros::WallTime last;
54 | int started;
55 |
56 | KinematicChain(int nlinks, int njoints);
57 |
58 | void setJointPosition(double *q, int n);
59 | void setJointVelocity(double *qdot, int n);
60 | void setJointPosition(std::vector &q, std::vector names = std::vector());
61 | void setJointVelocity(std::vector &qdot, std::vector names = std::vector());
62 | std::vector getJointPosition();
63 | std::vector getJointName();
64 | std::map getFullJointMap(); //Builds a map: name -> jointValue with all non-fixed joints (even mimic joints)
65 |
66 | /** Get the number of links */
67 | int getNumberOfLinks()
68 | {
69 | return link.size();
70 | }
71 | /** Get the number of joints*/
72 | int getNumberOfJoints()
73 | {
74 | return q.size();
75 | }
76 |
77 | ~KinematicChain();
78 |
79 | protected:
80 | virtual void updateJoints(std::vector &q)=0; ///< Implemented by childs for joint position update
81 | };
82 |
83 | #endif /* KINEMATICCHAIN_H_ */
84 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/LedArray.h:
--------------------------------------------------------------------------------
1 | #ifndef UWSIM_LEDARRAY_
2 | #define UWSIM_LEDARRAY_
3 |
4 | #include
5 | //#include
6 | //#include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | namespace uwsim {
18 |
19 | class LedArray {
20 | public:
21 | enum ledType { RED_LED, GREEN_LED };
22 | LedArray(osg::ref_ptr sceneRoot, LedArrayConfig config);
23 | osg::ref_ptr GetOSGNode();
24 | void StartAnimationTest();
25 | void UpdateLetState(ledType, bool);
26 |
27 | private:
28 | ros::NodeHandle nh;
29 | osg::ref_ptr sceneRoot;
30 | osg::ref_ptr vMRedLight;
31 | osg::ref_ptr vMGreenLight;
32 | osg::ref_ptr node;
33 | static uint32_t numLedLights;
34 | osg::ref_ptr greenLightSource, redLightSource;
35 | osg::ref_ptr greenLightMaterial, redLightMaterial;
36 | uint32_t redLightNum, greenLightNum;
37 | ros::Subscriber redLedSubscriber;
38 | ros::Subscriber greenLedSubscriber;
39 | std::thread ledWorker, testWorker;
40 | LedArrayConfig config;
41 |
42 | struct Action {
43 | ros::Time offTime;
44 | };
45 |
46 | //std::mutex actionsMutex;
47 | //std::condition_variable actionsCond;
48 | bool redStateOn, greenStateOn;
49 | Action redAction, greenAction;
50 |
51 | void InitROSInterface();
52 | void HandleNewLedState(underwater_sensor_msgs::LedLightConstPtr msg, ledType);
53 | void CheckAndUpdateLed(const ros::Time & now, ledType type, bool , const Action &);
54 | };
55 | }
56 | #endif
57 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/MultibeamSensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef MULTIBEAMSENSOR_H_
14 | #define MULTIBEAMSENSOR_H_
15 |
16 | #include "VirtualCamera.h"
17 |
18 | class MultibeamSensor
19 | {
20 | struct Remap
21 | {
22 | int pixel1, pixel2;
23 | double weight1, weight2;
24 | double distort;
25 | };
26 |
27 | public:
28 | std::vector vcams; //Virtual Cameras
29 | std::string name, parentLinkName;
30 | int numpixels, camPixels, nCams;
31 | double range, initAngle, finalAngle, angleIncr, camsFOV;
32 | osg::ref_ptr geode; //Geometry node that draws the beam
33 | std::vector remapVector;
34 | osg::Node *trackNode;
35 |
36 | MultibeamSensor(osg::Group *uwsim_root, std::string name, std::string parentName, osg::Node *trackNode, double initAngle, double finalAngle,
37 | double alpha, double range, unsigned int mask, int visible,unsigned int ARMask);
38 | void preCalcTable();
39 | int getTFTransform(tf::Pose & pose, std::string & parent);
40 | };
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/NED.h:
--------------------------------------------------------------------------------
1 | #ifndef UWSIM_NED_
2 | #define UWSIM_NED_
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace uwsim {
10 |
11 | class NED : public cpplogging::Logger{
12 | public:
13 | static void SetOrigin(double lat, double lon, double alt);
14 | static void GetNED(double lat, double lon, double alt, double &x, double &y, double &z);
15 |
16 | private:
17 | static GeographicLib::LocalCartesian localCartesian;
18 | static GeographicLib::Geocentric earth;
19 | static std::mutex localCartesian_mutex;
20 |
21 | };
22 |
23 | }
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/NetSim.h:
--------------------------------------------------------------------------------
1 | #ifndef UWSIM_NETSIM_
2 | #define UWSIM_NETSIM_
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace uwsim {
9 | using namespace dccomms_ros;
10 |
11 | class NetSimTracing : public cpplogging::Logger {
12 | public:
13 | NetSimTracing();
14 | void Run();
15 | virtual void Configure();
16 | virtual void DoRun();
17 | };
18 |
19 | typedef std::shared_ptr NetSimTracingPtr;
20 | class NetSim {
21 | public:
22 | static ns3::Ptr GetSim();
23 | static void LoadDefaultTracingScript();
24 | static void LoadTracingScript(const std::string &className,
25 | const std::string &libPath);
26 | static NetSimTracingPtr GetScript();
27 | private:
28 | static NetSimTracingPtr _script;
29 | static std::shared_ptr _loader;
30 |
31 | };
32 |
33 | }
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/ObjectPicker.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef OBJECTPICKER_H_
14 | #define OBJECTPICKER_H_
15 |
16 | #include "VirtualRangeSensor.h"
17 | #include "UWSimUtils.h"
18 | #include "URDFRobot.h"
19 | #include
20 |
21 | //Node tracker that updates the ray coordinates from the tracked node position, computes intersections and 'picks' nodes
22 | class ObjectPickerUpdateCallback : public IntersectorUpdateCallback
23 | {
24 | virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
25 | {
26 | osg::Matrixd mStart, mEnd;
27 | mStart = osg::computeLocalToWorld(nv->getNodePath());
28 | traverse(node, nv);
29 |
30 | //update ray and compute intersections. Checks intersections along X axis of the local frame
31 | mEnd = mStart;
32 | mEnd.preMultTranslate(osg::Vec3d(range, 0, 0));
33 |
34 | intersector->reset();
35 | intersector->setStart(mStart.getTrans());
36 | intersector->setEnd(mEnd.getTrans());
37 |
38 | root->accept(intersectVisitor);
39 |
40 | if (intersector->containsIntersections() && !picked)
41 | {
42 | osgUtil::LineSegmentIntersector::Intersection intersection = intersector->getFirstIntersection();
43 | osg::Vec3d worldIntPoint = intersection.getWorldIntersectPoint();
44 | distance_to_obstacle = (worldIntPoint - mStart.getTrans()).length();
45 | impact = intersection.nodePath;
46 |
47 | //search for catchable objects in nodepath
48 | for (osg::NodePath::iterator i = impact.begin(); i != impact.end(); ++i)
49 | {
50 | osg::ref_ptr data = dynamic_cast(i[0]->getUserData());
51 | if (data != NULL && data->catchable)
52 | {
53 |
54 | std::cerr << "Picking object up." << std::endl;
55 | //physics: set static object flag
56 | if (data->rigidBody)
57 | data->rigidBody->setCollisionFlags(
58 | data->rigidBody->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
59 |
60 | //add link to kinematic chain
61 | urdf->addToKinematicChain(i[0], data->rigidBody);
62 |
63 | osg::Node * objectTransf = i[0]->getParent(0)->getParent(0); //Object->linkBaseTransform->transform
64 |
65 | //Get coordinates to change them when changing position in graph
66 | std::shared_ptr originalpos = getWorldCoords(objectTransf);
67 | std::shared_ptr hand = getWorldCoords(trackNode);
68 | hand->invert(*hand);
69 |
70 | //ADD node in hand, remove object from original position.
71 | trackNode->asTransform()->addChild(objectTransf);
72 | objectTransf->getParent(0)->asGroup()->removeChild(objectTransf);
73 |
74 | osg::Matrixd matrix = *originalpos * *hand;
75 | objectTransf->asTransform()->asMatrixTransform()->setMatrix(matrix);
76 |
77 | picked = true;
78 | }
79 | }
80 | }
81 | else if (!picked)
82 | distance_to_obstacle = range;
83 | }
84 | public:
85 | osg::NodePath impact;
86 | osg::Node *trackNode;
87 | std::shared_ptr urdf;
88 | bool picked;
89 |
90 | ObjectPickerUpdateCallback(osg::Node *trackNode, double range, bool visible, osg::Node *root,
91 | std::shared_ptr urdf) :
92 | IntersectorUpdateCallback(range, visible, root)
93 | {
94 | this->trackNode = trackNode;
95 | picked = false;
96 | this->urdf = urdf;
97 | }
98 | };
99 |
100 | class ObjectPicker : public VirtualRangeSensor
101 | {
102 | public:
103 | ObjectPicker(std::string name, osg::Node *root, osg::Node *trackNode, double range, bool visible,
104 | std::shared_ptr urdf,unsigned int mask);
105 | ObjectPicker();
106 |
107 | void init(std::string name, osg::Node *root, osg::Node *trackNode, double range, bool visible,
108 | std::shared_ptr urdf,unsigned int mask);
109 | };
110 |
111 | #endif
112 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/PhysicsBuilder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef PHYSICSBUILDER_H
14 | #define PHYSICSBUILDER_H
15 |
16 | #include "SceneBuilder.h"
17 | #include "BulletPhysics.h"
18 | #include "ConfigXMLParser.h"
19 |
20 | class PhysicsBuilder
21 | {
22 | public:
23 | osg::ref_ptr physics;
24 | public:
25 |
26 | PhysicsBuilder(SceneBuilder * scene_builder, ConfigFile config);
27 | PhysicsBuilder()
28 | {
29 | }
30 | void loadPhysics(SceneBuilder * scene_builder, ConfigFile config);
31 |
32 | };
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/PressureSensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef PRESSURESENSOR_H_
14 | #define PRESSURESENSOR_H_
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 | #include
23 |
24 | class PressureSensor
25 | {
26 |
27 | public:
28 | std::string name, parentLinkName;
29 |
30 | /** Constructor
31 | * @param name the name of the pressure sensor
32 | * @param parentName the name of the link that holds the IMU
33 | * @param parent the node of the scene graph that holds the sensor
34 | * @param rMl the sensor measures are given with respect to the root (r). Use rMl to transform them to another frame ('l' is the new frame, typically the localized world)
35 | * @param std the standard deviation on the sensor measures
36 | */
37 | PressureSensor(std::string sensor_name, std::string parentName, osg::Node *parent, osg::Matrixd rMl, double std = 0) :
38 | name(sensor_name),parentLinkName(parentName) , parent_(parent), rMl_(rMl), std_(std)
39 | {
40 | node_ = new osg::Node();
41 | parent->asGroup()->addChild(node_);
42 | }
43 |
44 | double getMeasurement();
45 | int getTFTransform(tf::Pose & pose, std::string & parent);
46 |
47 | double getStandardDeviation()
48 | {
49 | return std_;
50 | }
51 |
52 | virtual ~PressureSensor()
53 | {
54 | }
55 |
56 | private:
57 | osg::ref_ptr parent_;
58 | osg::Matrixd rMl_;
59 | double std_;
60 | osg::ref_ptr node_;
61 |
62 | boost::mt19937 rng_; ///< Boost random number generator
63 | };
64 |
65 | #endif /* PRESSURESENSOR_H_ */
66 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/ROSSceneBuilder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 |
14 | #ifndef ROSSCENEBUILDER_H_
15 | #define ROSSCENEBUILDER_H_
16 |
17 | #include
18 |
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 |
26 | //This class extends the SceneBuilder with ROS interfaces to modify and interact with the scene geometry.
27 |
28 | class ROSSceneBuilder : public SceneBuilder
29 | {
30 |
31 | public:
32 |
33 | ROSSceneBuilder(std::shared_ptr args);
34 | bool loadScene(ConfigFile config);
35 |
36 | void updateIM();
37 |
38 | private:
39 |
40 | ros::NodeHandle n;
41 | ros::ServiceServer markerService;
42 | osg::Group * markers;
43 | std::shared_ptr frame_manager;
44 | std::shared_ptr marker_cli;
45 |
46 | ros::WallTime last_wall_time;
47 | ros::Time last_ros_time;
48 |
49 | typedef std::list< std::shared_ptr > MarkerList;
50 | MarkerList markerList;
51 |
52 | //This callback will receibe marker requests and create/modify/delete objects in the scene.
53 | bool markerSRVCallback(underwater_sensor_msgs::SpawnMarker::Request &req, underwater_sensor_msgs::SpawnMarker::Response &res);
54 |
55 |
56 | };
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SceneBuilder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef SCENEBUILDER_H
14 | #define SCENEBUILDER_H
15 |
16 | #include
17 | #include
18 |
19 | #include "osgOceanScene.h"
20 | #include "HUDCamera.h"
21 | #include "ROSInterface.h"
22 | #include "SimulatedIAUV.h"
23 | #include "ConfigXMLParser.h"
24 | #include
25 | #include
26 | #include
27 |
28 | class SceneBuilder
29 | {
30 | public:
31 | std::shared_ptr arguments;
32 | osg::ref_ptr scene;
33 | std::vector > iauvFile;
34 | std::vector > objects;
35 | std::vector > trajectories;
36 |
37 | osg::ref_ptr root;
38 |
39 | std::vector > realcams;
40 | std::vector > ROSInterfaces;
41 | std::vector > camWidgets;
42 | std::vector> customCommsChannels;
43 | std::vector> acousticCommsChannels;
44 | std::vector> ledArrays;
45 |
46 | public:
47 | SceneBuilder();
48 | SceneBuilder(int *argc, char **argv);
49 | SceneBuilder(std::shared_ptr args);
50 |
51 | bool loadScene(std::string xml_file);
52 | bool loadScene(ConfigFile config);
53 |
54 | osg::Group* getRoot()
55 | {
56 | return root.get();
57 | }
58 | osgOceanScene* getScene()
59 | {
60 | return scene.get();
61 | }
62 |
63 | ~SceneBuilder();
64 | };
65 |
66 | #endif
67 |
68 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SimDev_Echo.h:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 | //"Echo" example, SimulatedDevice_Echo.h
3 | #ifndef SIMULATEDDEVICE_ECHO_H_
4 | #define SIMULATEDDEVICE_ECHO_H_
5 | #include "SimulatedDevice.h"
6 | using namespace uwsim;
7 |
8 | /*
9 | * Example header of driver/rosinterface configuration/factory
10 | *
11 | * Included in SimulatedDevices.cpp
12 | */
13 |
14 | //Driver/ROSInterface configuration
15 | class SimDev_Echo_Config : public SimulatedDeviceConfig
16 | {
17 | public:
18 | //XML members
19 | std::string info;
20 | //constructor
21 | SimDev_Echo_Config(std::string type_) :
22 | SimulatedDeviceConfig(type_)
23 | {
24 | }
25 | };
26 |
27 | //Driver/ROSInterface factory class
28 | class SimDev_Echo_Factory : public SimulatedDeviceFactory
29 | {
30 | public:
31 | //this is the only place the device/interface type is set
32 | SimDev_Echo_Factory(std::string type_ = "echo") :
33 | SimulatedDeviceFactory(type_)
34 | {
35 | }
36 | ;
37 |
38 | SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node* node, ConfigFile * config);
39 | bool applyConfig(SimulatedIAUV * auv, Vehicle &vehicleChars, SceneBuilder *sceneBuilder, size_t iteration);
40 | std::vector > getInterface(ROSInterfaceInfo & rosInterface,
41 | std::vector > & iauvFile);
42 | };
43 |
44 | //can be a sparate header file for actual implementation classes...
45 |
46 | #include "ConfigXMLParser.h"
47 | #include "ROSInterface.h"
48 | #include
49 | #include
50 |
51 | //Driver class
52 | class SimDev_Echo : public SimulatedDevice
53 | {
54 | void applyPhysics(BulletPhysics * bulletPhysics)
55 | {
56 | }
57 | public:
58 | std::string info; //Device's property
59 |
60 | SimDev_Echo(SimDev_Echo_Config * cfg);
61 | };
62 |
63 | //ROS publishers and subscribers work exactly as before, no subclassing is needed
64 | class SimDev_Echo_ROSPublisher : public ROSPublisherInterface
65 | {
66 | //this is just an example, use a pointer to SimulatedIAUV, if only ROSInterface is implemented
67 | //pointer to a device
68 | SimDev_Echo * dev;
69 | public:
70 | SimDev_Echo_ROSPublisher(SimDev_Echo *dev, std::string topic, int rate) :
71 | ROSPublisherInterface(topic, rate), dev(dev)
72 | {
73 | }
74 |
75 | void createPublisher(ros::NodeHandle &nh);
76 | void publish();
77 |
78 | ~SimDev_Echo_ROSPublisher()
79 | {
80 | }
81 | };
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SimulatedDevice.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Tallinn University of Technology.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Yuri Gavshin
10 | */
11 |
12 | #ifndef SIMULATEDDEVICE_H_
13 | #define SIMULATEDDEVICE_H_
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | struct ROSInterfaceInfo;
22 | struct SimulatedIAUV;
23 | struct ROSInterface;
24 | struct ConfigFile;
25 | struct Vehicle;
26 | struct SceneBuilder;
27 | struct BulletPhysics;
28 | struct ViewBuilder;
29 |
30 | namespace uwsim
31 | {
32 | struct SimulatedDevice;
33 | //Base class for device's XML configuration
34 | class SimulatedDeviceConfig
35 | {
36 | //device/rosinterface type identifier for both "XML config" and a "factory"
37 | std::string type;
38 |
39 | public:
40 | typedef std::shared_ptr Ptr;
41 | //common XML properties:
42 | std::string name;
43 | std::string getType()
44 | {
45 | return type;
46 | }
47 |
48 | SimulatedDeviceConfig(std::string type);
49 | virtual ~SimulatedDeviceConfig()
50 | {
51 | }
52 | ;
53 | };
54 |
55 | //Base class for device/rosinterface "factory"
56 | class SimulatedDeviceFactory
57 | {
58 | //device/rosinterface type identifier for both "XML config" and a "factory"
59 | std::string type;
60 | public:
61 | typedef std::shared_ptr Ptr;
62 | std::string getType()
63 | {
64 | return type;
65 | }
66 | SimulatedDeviceFactory(std::string type);
67 |
68 | //DRIVER: parses XML and returns "XML config", executed first
69 | virtual SimulatedDeviceConfig::Ptr processConfig(const xmlpp::Node* node, ConfigFile * config) = 0;
70 | //DRIVER: checks parsed XML configurations and sets SimulatedAUV's data, executed second
71 | //Executed multiple times (to allow dependent devices work independent from order of ), until all factories return true
72 | //normally, configuration should occur only on iteration 0
73 | virtual bool applyConfig(SimulatedIAUV * auv, Vehicle &vehicleChars, SceneBuilder *oscene, size_t iteration) = 0;
74 | //ROSINTERFACE: returns configured ROSInterfaces, executed third
75 | virtual std::vector > getInterface(
76 | ROSInterfaceInfo & rosInterface, std::vector > & iauvFile)
77 | {
78 | std::vector < std::shared_ptr > ifaces;
79 | return ifaces;
80 | }
81 | ;
82 |
83 | virtual ~SimulatedDeviceFactory()
84 | {
85 | }
86 | ;
87 | };
88 |
89 | //Base class for a simulated device
90 | class SimulatedDevice
91 | {
92 | std::string type; //driver/rosinterface type
93 | public:
94 | std::string name; //common property
95 | std::string getType()
96 | {
97 | return type;
98 | }
99 | typedef std::shared_ptr Ptr;
100 | SimulatedDevice(SimulatedDeviceConfig * cfg);
101 | virtual void applyPhysics(BulletPhysics * bulletPhysics)
102 | {
103 | }
104 | virtual void setViewBuilder(ViewBuilder * viewBuilder)
105 | {
106 | }
107 |
108 | virtual ~SimulatedDevice()
109 | {
110 | }
111 | };
112 | }
113 | ;
114 |
115 | #endif /* SIMULATEDDEVICES_H_ */
116 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SimulatedDevices.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Tallinn University of Technology.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Yuri Gavshin
10 | */
11 |
12 | #ifndef SIMULATEDDEVICES_H_
13 | #define SIMULATEDDEVICES_H_
14 | #include "SimulatedDevice.h"
15 |
16 | //Class added to SimulatedIAUV as devices->, put your data into into this class members or use all vector to store your device
17 | class SimulatedDevices
18 | {
19 | public:
20 | //Object members
21 | std::vector all;
22 |
23 | SimulatedDevices();
24 |
25 | //Applies parsed XML configurations by calling appropriate methods
26 | //on all registered factories (set in initFactories() in SimulatedDevices.cpp)
27 | void applyConfig(SimulatedIAUV * auv, Vehicle &vehicleChars, SceneBuilder *oscene);
28 |
29 | //Factory methods
30 |
31 | //returns configured ROSInterface based on given XML configuration
32 | static std::vector > getInterfaces(
33 | ROSInterfaceInfo & rosInterface, std::vector > & iauvFile);
34 |
35 | //Parses driver's XML configuration
36 | static std::vector processConfig(const xmlpp::Node* node, ConfigFile * config,
37 | bool isDevice = false);
38 | };
39 | #endif /* SIMULATEDDEVICES_H_ */
40 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SimulatedIAUV.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef SIMULATEDIAUV_H_
14 | #define SIMULATEDIAUV_H_
15 |
16 | #include "osgOceanScene.h"
17 | #include "URDFRobot.h"
18 | #include "VirtualCamera.h"
19 | #include "ConfigXMLParser.h"
20 | #include "VirtualRangeSensor.h"
21 | #include "VirtualSLSProjector.h"
22 | #include "ObjectPicker.h"
23 | #include "InertialMeasurementUnit.h"
24 | #include "PressureSensor.h"
25 | #include "GPSSensor.h"
26 | #include "DVLSensor.h"
27 | #include "MultibeamSensor.h"
28 | #include
29 | #include
30 |
31 | class SceneBuilder;
32 |
33 | /* An I-AUV */
34 | class SimulatedIAUV
35 | {
36 | public:
37 | std::vector camview;
38 | std::vector range_sensors;
39 | std::vector sls_projectors;
40 | std::vector object_pickers;
41 | std::vector imus;
42 | std::vector pressure_sensors;
43 | std::vector gps_sensors;
44 | std::vector dvl_sensors;
45 | std::vector multibeam_sensors;
46 | std::shared_ptr devices;
47 | osg::ref_ptr root;
48 | std::shared_ptr ledArray;
49 |
50 | typedef enum
51 | {
52 | ARM5, PA10
53 | } arm_t;
54 |
55 | std::string name; ///< Vehicle name
56 | std::shared_ptr urdf; ///< URDF I-AUV
57 | //osg::LightSource* lightSource; ///< vehicle lamp
58 | osg::ref_ptr baseTransform;
59 | std::mutex baseTransform_mutex;
60 | osg::Vec3d scale; //Vehicle scale factor
61 |
62 | SimulatedIAUV(SceneBuilder *oscene, Vehicle vehicle);
63 |
64 | //void setVirtualCamera(std::string name, osg::Transform* transform, osg::Vec3d eye, osg::Vec3d orientation, osg::Vec3d upVector, int width, int height);
65 |
66 | //setPosition
67 | void setVehiclePosition(double x, double y, double z, double yaw)
68 | {
69 | setVehiclePosition(x, y, z, 0, 0, yaw);
70 | }
71 | void setVehiclePosition(double x, double y, double z, double roll, double pitch, double yaw);
72 | void setVehiclePosition(double p[6])
73 | {
74 | setVehiclePosition(p[0], p[1], p[2], p[3], p[4], p[5]);
75 | }
76 | void setVehiclePosition(osg::Matrixd m);
77 |
78 | unsigned int getNumCams()
79 | {
80 | return camview.size();
81 | }
82 | unsigned int getNumRangeSensors()
83 | {
84 | return range_sensors.size();
85 | }
86 | unsigned int getNumObjectPickers()
87 | {
88 | return object_pickers.size();
89 | }
90 |
91 | ~SimulatedIAUV()
92 | {
93 | OSG_DEBUG << "Simulated IAUV destructor" << std::endl;
94 | }
95 | };
96 |
97 | #endif /* SIMULATEDIAUV_H_ */
98 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SimulatorConfig.h.cmake:
--------------------------------------------------------------------------------
1 | #ifndef SIMULATORCONFIG_H
2 | #define SIMULATORCONFIG_H
3 |
4 | #ifndef M_PI
5 | #define M_PI 3.14159265358979323846
6 | #endif
7 | #ifndef M_PI_2
8 | #define M_PI_2 M_PI/2
9 | #endif
10 | #ifndef M_PI_4
11 | #define M_PI_4 M_PI/4
12 | #endif
13 |
14 | #include
15 |
16 | #ifndef OSG_FATAL
17 | #define OSG_FATAL osg::notify(osg::FATAL)
18 | #endif
19 |
20 | #ifndef OSG_ERROR
21 | #define OSG_ERROR osg::notify(osg::ERROR)
22 | #endif
23 |
24 | #ifndef OSG_WARN
25 | #define OSG_WARN osg::notify(osg::WARN)
26 | #endif
27 |
28 | #ifndef OSG_INFO
29 | #define OSG_INFO osg::notify(osg::INFO)
30 | #endif
31 |
32 | #ifndef OSG_DEBUG
33 | #define OSG_DEBUG osg::notify(osg::DEBUG_INFO)
34 | #endif
35 |
36 | //Build ROS interfaces
37 | #cmakedefine BUILD_ROS_INTERFACES ${BUILD_ROS_INTERFACES}
38 |
39 | //Build Bullet physics
40 | #cmakedefine BUILD_BULLET_PHYSICS ${BUILD_BULLET_PHYSICS}
41 |
42 | //UWSim root folder
43 | #cmakedefine UWSIM_ROOT_PATH "${UWSIM_ROOT_PATH}"
44 |
45 | //Operating system
46 | #cmakedefine WIN32 ${WIN32}
47 | #cmakedefine UNIX ${UNIX}
48 | #cmakedefine APPLE ${APPLE}
49 |
50 | #endif
51 |
52 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SkyDome.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of the osgOcean library
3 | *
4 | * Copyright (C) 2009 Kim Bale
5 | * Copyright (C) 2009 The University of Hull, UK
6 | *
7 | * This program is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free Software
9 | * Foundation; either version 3 of the License, or (at your option) any later
10 | * version.
11 |
12 | * This program is distributed in the hope that it will be useful, but WITHOUT
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15 | * http://www.gnu.org/copyleft/lesser.txt.
16 | */
17 |
18 | #pragma once
19 | #include "SphereSegment.h"
20 | #include
21 | #include
22 | #include
23 |
24 | class SkyDome : public SphereSegment
25 | {
26 | public:
27 | SkyDome(void);
28 | SkyDome(const SkyDome& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
29 | SkyDome(float radius, unsigned int longSteps, unsigned int latSteps, osg::TextureCubeMap* cubemap);
30 |
31 | protected:
32 | ~SkyDome(void);
33 |
34 | public:
35 | void setupStateSet(osg::TextureCubeMap* cubemap);
36 | void create(float radius, unsigned int latSteps, unsigned int longSteps, osg::TextureCubeMap* cubemap);
37 |
38 | inline void setCubeMap(osg::TextureCubeMap* cubemap)
39 | {
40 | getOrCreateStateSet()->setTextureAttributeAndModes(0, cubemap, osg::StateAttribute::ON);
41 | }
42 |
43 | private:
44 | osg::ref_ptr createShader(void);
45 |
46 | };
47 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/SphereSegment.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of the osgOcean library
3 | *
4 | * Copyright (C) 2009 Kim Bale
5 | * Copyright (C) 2009 The University of Hull, UK
6 | *
7 | * This program is free software; you can redistribute it and/or modify it under
8 | * the terms of the GNU Lesser General Public License as published by the Free Software
9 | * Foundation; either version 3 of the License, or (at your option) any later
10 | * version.
11 |
12 | * This program is distributed in the hope that it will be useful, but WITHOUT
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15 | * http://www.gnu.org/copyleft/lesser.txt.
16 | */
17 |
18 | #pragma once
19 | #include
20 | #include
21 |
22 | class SphereSegment : public osg::Geode
23 | {
24 | public:
25 | SphereSegment(void);
26 |
27 | SphereSegment(float radius, unsigned int longitudeSteps, unsigned int lattitudeSteps, float longStart, float longEnd,
28 | float latStart, float latEnd);
29 |
30 | SphereSegment(const SphereSegment& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
31 |
32 | protected:
33 | ~SphereSegment(void);
34 |
35 | public:
36 | // 0 >= longStart/longEnd <= 180
37 | // 0 >= latStart/latEnd <= 360
38 | void compute(float radius, unsigned int longitudeSteps, unsigned int lattitudeSteps, float longStart, float longEnd,
39 | float latStart, float latEnd);
40 | private:
41 | osg::Vec2 sphereMap(osg::Vec3& vertex, float radius);
42 |
43 | inline unsigned int idx(unsigned int r, unsigned int c, unsigned int row_len)
44 | {
45 | return c + r * row_len;
46 | }
47 | };
48 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/TextHUD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | // ----------------------------------------------------
14 | // Text HUD Class
15 | // ----------------------------------------------------
16 | #include
17 |
18 | class TextHUD : public osg::Referenced
19 | {
20 | private:
21 | osg::ref_ptr _camera;
22 | osg::ref_ptr _modeText;
23 | osg::ref_ptr _cameraModeText;
24 |
25 | public:
26 | TextHUD(void)
27 | {
28 | _camera = createCamera();
29 | _camera->addChild(createText());
30 | }
31 |
32 | osg::Camera* createCamera(void)
33 | {
34 | osg::ref_ptr camera = new osg::Camera;
35 |
36 | camera->setViewport(0, 0, 1024, 768);
37 | camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
38 | camera->setProjectionMatrixAsOrtho2D(0, 1024, 0, 768);
39 | camera->setRenderOrder(osg::Camera::POST_RENDER);
40 | camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
41 | camera->setClearMask(GL_DEPTH_BUFFER_BIT);
42 | // camera->setProjectionResizePolicy(osg::Camera::VERTICAL);
43 |
44 | return camera.release();
45 | }
46 |
47 | osg::Node* createText(void)
48 | {
49 | osg::Geode* textGeode = new osg::Geode;
50 |
51 | osgText::Text* title = new osgText::Text;
52 | //title->setFont("fonts/arial.ttf");
53 | title->setCharacterSize(24);
54 | title->setLineSpacing(0.4f);
55 |
56 | std::string versionText = std::string("\nPress 'h' for options");
57 |
58 | title->setText(versionText);
59 | textGeode->addDrawable(title);
60 |
61 | _modeText = new osgText::Text;
62 | //_modeText->setFont("fonts/arial.ttf");
63 | _modeText->setCharacterSize(24);
64 | _modeText->setPosition(osg::Vec3f(0.f, -40.f, 0.f));
65 | _modeText->setDataVariance(osg::Object::DYNAMIC);
66 | textGeode->addDrawable(_modeText.get());
67 |
68 | _cameraModeText = new osgText::Text;
69 | //_cameraModeText->setFont("fonts/arial.ttf");
70 | _cameraModeText->setCharacterSize(24);
71 | _cameraModeText->setPosition(osg::Vec3f(0.f, -60.f, 0.f));
72 | _cameraModeText->setDataVariance(osg::Object::DYNAMIC);
73 | //textGeode->addDrawable( _cameraModeText.get() );
74 |
75 | osg::PositionAttitudeTransform* titlePAT = new osg::PositionAttitudeTransform;
76 | titlePAT->setPosition(osg::Vec3f(10, 70, 0.f));
77 | //titlePAT->addChild(textGeode);
78 |
79 | return titlePAT;
80 | }
81 |
82 | void setSceneText(const std::string& preset)
83 | {
84 | _modeText->setText("\nWeather: " + preset + "\n");
85 | }
86 |
87 | void setCameraText(const std::string& mode)
88 | {
89 | _cameraModeText->setText("Camera: " + mode);
90 | }
91 |
92 | osg::Camera* getHudCamera(void)
93 | {
94 | return _camera.get();
95 | }
96 | };
97 |
--------------------------------------------------------------------------------
/uwsim/include/uwsim/URDFRobot.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 University of Jaume-I.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the GNU Public License v3.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.gnu.org/licenses/gpl.html
7 | *
8 | * Contributors:
9 | * Mario Prats
10 | * Javier Perez
11 | */
12 |
13 | #ifndef URDFROBOT_H_
14 | #define URDFROBOT_H_
15 |
16 | #include "SimulatorConfig.h"
17 | #include "KinematicChain.h"
18 | #include "ConfigXMLParser.h"
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | class URDFRobot : public KinematicChain
27 | {
28 |
29 | public:
30 |
31 | std::vector joint_axis;
32 | std::string URDFFile;
33 |
34 | URDFRobot(osgOcean::OceanScene *oscene, Vehicle vehicle);
35 | void addToKinematicChain(osg::Node * link, btRigidBody* body);
36 |
37 | ~URDFRobot();
38 |
39 | protected:
40 |
41 | void updateJoints(std::vector &q);
42 | void updateJoints(std::vector