ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

copy.deepcopy is the recommended way of creating a deep copy of a message, according to this ticket.

copy.deepcopy is the recommended way of creating a deep copy of a message, according to this ticket.

Edit: You probably named a function copy after the import line. Python has only one namespace, i.e. by defining a function copy, you overwrite the package copy. Either do a from copy import deepcopy and just call deepcopy, not copy.deepcopy or rename your function.

copy.deepcopy is the recommended way of creating a deep copy of a message, according to this ticket.

Edit: You probably named a function copy after the import line. Python has only one namespace, i.e. by defining a function copy, you overwrite the package copy. Either do a

from copy import deepcopy deepcopy

and just call deepcopy, not copy.deepcopy or rename your function.function. You can also import the module copy under a different name:

import copy as copy_module

copy.deepcopy is the recommended way of creating a deep copy of a message, according to this ticket.

Edit: You probably named a function copy after the import line. Python has only one namespace, i.e. by defining a function copy, you overwrite the package copy. Either do

from copy import deepcopy

and just call deepcopy, not copy.deepcopy or rename your function. You can also import the module copy under a different name:

import copy as copy_module

Then you can call the deepcopy function like this:

new_odometry = copy_module.deepcopy(odometry)

copy.deepcopy is the recommended way of creating a deep copy of a message, according to this ticket.

Edit: You probably named a function copy after the import line. Python has only one namespace, i.e. by defining a function copy, you overwrite the package copy. Either do

from copy import deepcopy

and just call deepcopy, not copy.deepcopy or rename your function. You can also import the module copy under a different name:

import copy as copy_module

Then you can call the deepcopy function like this:

new_odometry odom_new = copy_module.deepcopy(odometry)
copy_module.deepcopy(odom_old)

copy.deepcopy is the recommended way of creating a deep copy of a message, according to this ticket.

Edit: You probably named a function copy after the import line. Python has only one namespace, namespace for variables and functions (in contrast to Common Lisp for instance), i.e. by defining naming a function copy, copy, you overwrite the package copy. copy. Either do

from copy import deepcopy

and just call deepcopy, deepcopy, not copy.deepcopy copy.deepcopy or rename your function. You can also import the module copy under a different name:

import copy as copy_module

Then you can call the deepcopy function like this:

odom_new = copy_module.deepcopy(odom_old)