BCLab-UNM / SwarmathonIV-Cabrillo-Public

Swarmathon code repository for Cabrillo College
MIT License
6 stars 1 forks source link

Public swarmie methods return references to internal objects #161

Open darrenchurchill opened 5 years ago

darrenchurchill commented 5 years ago

Not that anyone would mess with the internals intentionally, but it can be done, perhaps by mistake. The copy module has a deep_copy method that's useful.

A trivial example:

>>> b = swarmie.get_targets_buffer()
>>> b[0].pose.pose = Pose()
>>> swarmie.get_targets_buffer()

[id: 0
 size: 0.038
 pose: 
   header: 
     seq: 1871
     stamp: 
       secs: 26209
       nsecs: 950000000
     frame_id: "achilles/camera_link"
   pose: 
     position: 
       x: 0.0
       y: 0.0
       z: 0.0
     orientation: 
       x: 0.0
       y: 0.0
       z: 0.0
       w: 0.0, id: 0
 size: 0.038
 pose: 
   header: 
     seq: 1870
     stamp: 
       secs: 26209
       nsecs: 781000000
     frame_id: "achilles/camera_link"
   pose: 
     position: 
       x: 0.083398284044
       y: -0.0649271479238
       z: 0.29192383131
     orientation: 
       x: 0.886939378472
       y: -0.0769903018106
       z: 0.0418957762061
       w: 0.453492862435]
Carter90 commented 5 years ago

Good point, don't have time for that