Skip to content

Commit

Permalink
implemented sun rotation during dataset generation #91
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefdre committed Feb 13, 2023
1 parent f806726 commit 607cbd4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
10 changes: 5 additions & 5 deletions synfeal_collection/model3d_config/santuario.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ volume:
light:
light_names:
- 'user_point_light_0'
- 'user_point_light_1'
- 'user_point_light_2'
- 'user_point_light_3'
- 'user_point_light_4'
- 'user_point_light_5'
# - 'user_point_light_1'
# - 'user_point_light_2'
# - 'user_point_light_3'
# - 'user_point_light_4'
# - 'user_point_light_5'
att_initial: 1.0
att_min: 0.1
att_max: 1.0
Expand Down
4 changes: 4 additions & 0 deletions synfeal_collection/scripts/data_collector
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def main():
if args['use_variable_lights']:
light = data_collector.generateLights(n_steps=1, random=True)
data_collector.setLight(light)
sun_light = data_collector.generateSunLight()
data_collector.setSunLight(sun_light)
data_collector.setPose(pose)
# todo: use getmodelstate from gazebo instead of waiting...
rospy.sleep(0.6)
Expand Down Expand Up @@ -105,6 +107,8 @@ def main():
data_collector.setPose(pose)
if args['use_variable_lights']:
data_collector.setLight(step_lights[idx])
sun_light = data_collector.generateSunLight()
data_collector.setSunLight(sun_light)
if not args['fast']:
rospy.sleep(0.4)
else:
Expand Down
26 changes: 19 additions & 7 deletions synfeal_collection/src/automatic_data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import tf
import numpy as np
import trimesh
from geometry_msgs.msg import Pose , Quaternion , Point
from geometry_msgs.msg import Pose , Quaternion , Point , Vector3
#from interactive_markers.interactive_marker_server import *
#from interactive_markers.menu_handler import *
from visualization_msgs.msg import *
Expand Down Expand Up @@ -230,20 +230,32 @@ def setLight(self, light):
f.write(my_str)

os.system(
f'gz topic -p /gazebo/santuario_Light/light/modify -f /tmp/set_light.txt')
f'gz topic -p /gazebo/santuario/light/modify -f /tmp/set_light.txt')

def generateSun(self):
sun = np.random.uniform(low=self.sun_min, high=self.sun_max)
return sun
def generateSunLight(self):
pitch = np.random.uniform(low=-1.57, high=1.57)
return pitch

def setSun(self, sun):
def setSunLight(self, roll = 0, pitch = 0, yaw = 0):
pose = Pose()
pose.position = Point(0,0,10)
pose.orientation = Quaternion(0,2,0,1)
orientation = tf.transformations.quaternion_from_euler(roll, pitch, yaw)
pose.orientation = Quaternion(0,0,0,1)
pose.orientation.x = orientation[0]
pose.orientation.y = orientation[1]
pose.orientation.z = orientation[2]
pose.orientation.w = orientation[3]

light = SetLightPropertiesRequest()
light.light_name = 'sun'
light.cast_shadows = True
light.diffuse = ColorRGBA(0.8,0.8,0.8,1)
light.specular = ColorRGBA(0.2,0.2,0.2,1)
light.attenuation_constant = 0.9
light.attenuation_linear = 0.01
light.attenuation_quadratic = 0.001
light.pose = pose
light.direction = Vector3(0,0,-1)

rospy.wait_for_service('/gazebo/set_light_properties')
try:
Expand Down

0 comments on commit 607cbd4

Please sign in to comment.