Skip to content

Commit

Permalink
Copy and pass pointer instead of full object
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Dec 11, 2019
1 parent d73008f commit a4bac76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool CanBusControlboard::open(yarp::os::Searchable & config)
return false;
}

const auto * robotConfig = reinterpret_cast<const yarp::os::Property *>(config.find("robotConfig").asBlob());
const auto * robotConfig = *reinterpret_cast<yarp::os::Property * const *>(config.find("robotConfig").asBlob());

int parallelCanThreadLimit = config.check("parallelCanThreadLimit", yarp::os::Value(0), "parallel CAN TX thread limit").asInt32();

Expand Down
4 changes: 3 additions & 1 deletion libraries/YarpPlugins/TechnosoftIpos/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bool TechnosoftIpos::open(yarp::os::Searchable & config)
return false;
}

const auto * robotConfig = reinterpret_cast<const yarp::os::Property *>(config.find("robotConfig").asBlob());
const auto * robotConfig = *reinterpret_cast<const yarp::os::Property * const *>(config.find("robotConfig").asBlob());

int canId = config.check("canId", yarp::os::Value(0), "CAN node ID").asInt32();

Expand Down Expand Up @@ -92,12 +92,14 @@ bool TechnosoftIpos::open(yarp::os::Searchable & config)
}
}

/* FIXME
linInterpBuffer = LinearInterpolationBuffer::createBuffer(config);
if (!linInterpBuffer)
{
return false;
}
*/

double canSdoTimeoutMs = config.check("canSdoTimeoutMs", yarp::os::Value(0.0), "CAN SDO timeout (ms)").asFloat64();
double canDriveStateTimeout = config.check("canDriveStateTimeout", yarp::os::Value(0.0), "CAN drive state timeout (s)").asFloat64();
Expand Down
5 changes: 3 additions & 2 deletions programs/launchCanBus/LaunchCanBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf)
}

yarp::os::Property robotConfig;
const auto * robotConfigPtr = &robotConfig;
std::string configPath = rf.findFileByName("config.ini");

if (configPath.empty() || !robotConfig.fromConfigFile(configPath))
Expand Down Expand Up @@ -77,7 +78,7 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf)

yarp::os::Property canDeviceOptions;
canDeviceOptions.fromString(canDeviceGroup.toString());
canDeviceOptions.put("robotConfig", yarp::os::Value::makeBlob(&robotConfig, sizeof(robotConfig)));
canDeviceOptions.put("robotConfig", yarp::os::Value::makeBlob(&robotConfigPtr, sizeof(robotConfigPtr)));
canDeviceOptions.put("home", homing);

yarp::dev::PolyDriver * canDevice = new yarp::dev::PolyDriver;
Expand Down Expand Up @@ -141,7 +142,7 @@ bool LaunchCanBus::configure(yarp::os::ResourceFinder &rf)

yarp::os::Property calibratorDeviceOptions;
calibratorDeviceOptions.fromString(calibratorDeviceGroup.toString());
calibratorDeviceOptions.put("robotConfig", yarp::os::Value::makeBlob(&robotConfig, sizeof(robotConfig)));
calibratorDeviceOptions.put("robotConfig", yarp::os::Value::makeBlob(&robotConfigPtr, sizeof(robotConfigPtr)));
calibratorDeviceOptions.put("joints", wrapperDeviceOptions.find("joints"));

yarp::dev::PolyDriver * calibratorDevice = new yarp::dev::PolyDriver;
Expand Down

0 comments on commit a4bac76

Please sign in to comment.