Discussion:
[Rock-dev] Modifying a complex properties from ruby
Ajish Babu
2014-09-04 18:19:56 UTC
Permalink
Hi all,

I have a complex property with std::vector (sub-configs) inside
std:vector (configs). I am trying to modify the property from ruby script.

Changing any already existing value works fine. But once I try to push a
new element to the sub-configs and then write it back like

configs = task.configs.to_a

configs.each do | config |
sub_configs = config.sub_configs.to_a
sub_configs.push( Types::SubConfig.new )
config.sub_configs = sub_configs
end

task.configs = configs

it crashes. Does anybody know how this can be achieved?

Best
Ajish



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dfki.de/pipermail/rock-dev/attachments/20140904/93425efe/attachment.htm
Sylvain Joyeux
2014-09-05 13:48:27 UTC
Permalink
Could you be more specific as to the type of property.

Moreover, do you try to change the property while the component is running ?

Sylvain
Post by Ajish Babu
Hi all,
I have a complex property with std::vector (sub-configs) inside std:vector
(configs). I am trying to modify the property from ruby script.
Changing any already existing value works fine. But once I try to push a new
element to the sub-configs and then write it back like
configs = task.configs.to_a
configs.each do | config |
sub_configs = config.sub_configs.to_a
sub_configs.push( Types::SubConfig.new )
config.sub_configs = sub_configs
end
task.configs = configs
it crashes. Does anybody know how this can be achieved?
Best
Ajish
_______________________________________________
Rock-dev mailing list
Rock-dev at dfki.de
http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev
Ajish Babu
2014-09-05 16:24:18 UTC
Permalink
Post by Sylvain Joyeux
Could you be more specific as to the type of property.
I have the following types, in effect four nested std::vector types

namespace ndlcom_device_driver
{
struct ConfigureRegisterBit {
std::string name;
int bit;
bool value;t
};

typedef std::vector< ConfigureRegisterBit > ConfigureRegisterBits;

struct ConfigureRegister {
std::string name;
representations::RegisterId id;
double value;
ConfigureRegisterBits bits;
std::string valueString;
};

typedef std::vector< ConfigureRegister > ConfigureRegisters;

struct DeviceClassRegister {
std::string deviceclass;
ConfigureRegisters registers;
};

typedef std::vector< DeviceClassRegister > DeviceClassRegisters;

struct JointConfig {
std::string jointName;
DeviceClassRegisters configureRegisters;
};

typedef std::vector< JointConfig > JointsConfig;
}

The task property is of type JointsConfig. In the ruby script I do

joints_config = task.joints_config.to_a
joints_config.each do | joint_config |
configureRegisters = joint_config.configureRegisters.to_a
configureRegisters.push(
Types::NdlcomDeviceDriver::DeviceClassRegister.new )
joint_config.configureRegisters = configureRegisters
end
task.joints_config = joints_config # This is where it crashes

I also tried something like.

joints_config.each do | joint |
joint.configureRegisters.push(
Types::NdlcomDeviceDriver::DeviceClassRegister.new )
joint.configureRegisters.each do | dc |
dc.registers.push(
Types::NdlcomDeviceDriver::ConfigureRegister.new )
dc.registers.each do | reg |
reg.bits.push(
Types::NdlcomDeviceDriver::ConfigureRegisterBit.new )
end
end
end

The difference is that then the problem is changing from crash to
following error message.

install/lib/ruby/1.9.1/typelib/compound_type.rb:23:in `set':
invalidated object for
/ndlcom_device_driver/DeviceClassRegister.registers for
/ndlcom_device_driver/JointConfig.configureRegisters (TypeError)

Let me know if you need more info.
Post by Sylvain Joyeux
Moreover, do you try to change the property while the component is running ?
No the task is not running.

Best
Ajish
Post by Sylvain Joyeux
Sylvain
Post by Ajish Babu
Hi all,
I have a complex property with std::vector (sub-configs) inside std:vector
(configs). I am trying to modify the property from ruby script.
Changing any already existing value works fine. But once I try to push a new
element to the sub-configs and then write it back like
configs = task.configs.to_a
configs.each do | config |
sub_configs = config.sub_configs.to_a
sub_configs.push( Types::SubConfig.new )
config.sub_configs = sub_configs
end
task.configs = configs
it crashes. Does anybody know how this can be achieved?
Best
Ajish
_______________________________________________
Rock-dev mailing list
Rock-dev at dfki.de
http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dfki.de/pipermail/rock-dev/attachments/20140905/20021402/attachment-0001.htm
Loading...