#! /usr/bin/env morseexec
""" Basic MORSE simulation scene for <sim_tests> environment
Feel free to edit this template as you like!
"""
from morse.builder import *
robot = Morsy()
robot.translate(1.0, 0.0, 0.0)
robot.rotate(0.0, 0.0, 3.5)
# Add a keyboard controller to move the robot with arrow keys.
keyboard = Keyboard()
robot.append(keyboard)
keyboard.properties(ControlType='Position')
# Add the gps
gps = GPS()
gps.add_stream('ros')
gps.alter('geodetic')
robot.append(gps)
robot.add_default_interface('socket')
# set 'fastmode' to True to switch to wireframe mode
env = Environment('sandbox', fastmode=False)
env.set_camera_location([-18.0, -6.7, 10.8])
env.set_camera_rotation([1.09, 0, -1.14])
env.properties(latitude=1.53, longitude=45.1, altitude=0)
If you launch this simulation and monitor the topic /robot/gps, you will see that latitude, longitude are respectively 45.1 and 1.53, instead of (1.53 and 45.1 as defined in the script)
Solution proposition
Inverting x and y in the publisher, modifier or coordinates transforms
I'm not sure at which level this invertion appears. It might appear:
In the publisher associated with the gps: NavSatFixPublisher, where longitude is defined as y instead of x.
In the modifier geodetic.py, where lines 36/37 (or 45/46) should inversed.
By using another level of abstraction of the GPS sensor
There is also another way to use geodetic coordinates with a GPS sensor (using abstraction levels):
gps = GPS()
gps.level('raw')
In this case, the local_data x,y,z of the sensor are not set. But: local_data['longitude'], local_data['latitude'], local_data['altitude'] are set instead.
However you cannot use the default ros publisher for gps which is: NavSatFixPublisher, for two reasons:
This publisher uses data['x'] as the latitude and data['y'] as the longitude. (instead of data['latitude'] and data['longitude'])
When using a different level of abstraction (here, to raw), the class of gps sensor becomes RawGPS, which doesn't have a publisher associated (see MORSE_DATASTREAM_DICT in data.py
One solution might be to create another ROSPublisher associated with RawGPS.
Problem
Minimal code to reproduce the problem:
If you launch this simulation and monitor the topic
/robot/gps
, you will see that latitude, longitude are respectively 45.1 and 1.53, instead of (1.53 and 45.1 as defined in the script)Solution proposition
Inverting x and y in the publisher, modifier or coordinates transforms
I'm not sure at which level this invertion appears. It might appear:
ecef_to_geodetic
in module helpers/coordinates.pyBy using another level of abstraction of the GPS sensor
There is also another way to use geodetic coordinates with a GPS sensor (using abstraction levels):
In this case, the local_data x,y,z of the sensor are not set. But:
local_data['longitude']
,local_data['latitude']
,local_data['altitude']
are set instead. However you cannot use the default ros publisher for gps which is: NavSatFixPublisher, for two reasons:data['x']
as the latitude anddata['y']
as the longitude. (instead ofdata['latitude']
anddata['longitude']
)raw
), the class of gps sensor becomesRawGPS
, which doesn't have a publisher associated (seeMORSE_DATASTREAM_DICT
in data.pyOne solution might be to create another ROSPublisher associated with
RawGPS
.