mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-12 19:10:47 +02:00
implemented setting of speed_slider via ROS topic
This commit is contained in:
@@ -216,6 +216,8 @@ bool HardwareInterface ::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_h
|
||||
}
|
||||
tool_data_pub_.reset(new realtime_tools::RealtimePublisher<ur_msgs::ToolDataMsg>(robot_hw_nh, "tool_data", 1));
|
||||
|
||||
speed_slider_sub_ = robot_hw_nh.subscribe("set_speed_slider", 10, &HardwareInterface::speedScalingCallback, this);
|
||||
|
||||
deactivate_srv_ = robot_hw_nh.advertiseService("hand_back_control", &HardwareInterface::stopControl, this);
|
||||
|
||||
ROS_INFO_STREAM_NAMED("hardware_interface", "Loaded ur_rtde_driver hardware_interface");
|
||||
@@ -533,4 +535,9 @@ bool HardwareInterface::stopControl(std_srvs::TriggerRequest& req, std_srvs::Tri
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HardwareInterface::speedScalingCallback(const std_msgs::Float64::ConstPtr& msg)
|
||||
{
|
||||
ur_driver_->getRTDEWriter().sendSpeedSlider(msg->data);
|
||||
}
|
||||
} // namespace ur_driver
|
||||
|
||||
@@ -40,7 +40,7 @@ RTDEClient::RTDEClient(std::string robot_ip, comm::INotifier& notifier, const st
|
||||
, parser_(recipe_)
|
||||
, prod_(stream_, parser_)
|
||||
, pipeline_(prod_, PIPELINE_NAME, notifier)
|
||||
, writer_(&stream_, input_recipe_file)
|
||||
, writer_(&stream_, input_recipe_)
|
||||
, max_frequency_(URE_MAX_FREQUENCY)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,35 +31,63 @@ namespace ur_driver
|
||||
{
|
||||
namespace rtde_interface
|
||||
{
|
||||
RTDEWriter::RTDEWriter(comm::URStream<PackageHeader>* stream, const std::string& recipe_file) : stream_(stream)
|
||||
RTDEWriter::RTDEWriter(comm::URStream<PackageHeader>* stream, const std::vector<std::string>& recipe)
|
||||
: stream_(stream), recipe_(recipe), queue_{ 32 }
|
||||
{
|
||||
}
|
||||
|
||||
bool RTDEWriter::init(uint8_t recipe_id)
|
||||
void RTDEWriter::init(uint8_t recipe_id)
|
||||
{
|
||||
return false;
|
||||
recipe_id_ = recipe_id;
|
||||
writer_thread_ = std::thread(&RTDEWriter::run, this);
|
||||
}
|
||||
bool RTDEWriter::start()
|
||||
|
||||
void RTDEWriter::run()
|
||||
{
|
||||
return false;
|
||||
uint8_t buffer[4096];
|
||||
size_t size;
|
||||
size_t written;
|
||||
std::unique_ptr<DataPackage> package;
|
||||
while (true)
|
||||
{
|
||||
queue_.waitDequeue(package);
|
||||
package->setRecipeID(recipe_id_);
|
||||
size = package->serializePackage(buffer);
|
||||
stream_->write(buffer, size, written);
|
||||
}
|
||||
}
|
||||
|
||||
bool RTDEWriter::sendSpeedSlider(double speed_slider_fraction)
|
||||
{
|
||||
return false;
|
||||
std::unique_ptr<DataPackage> package;
|
||||
package.reset(new DataPackage(recipe_));
|
||||
package->initEmpty();
|
||||
uint32_t mask = 1;
|
||||
package->setData("speed_slider_mask", mask);
|
||||
package->setData("speed_slider_fraction", speed_slider_fraction);
|
||||
|
||||
if (!queue_.tryEnqueue(std::move(package)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTDEWriter::sendStandardDigitalOutput(uint8_t output_pin, bool value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTDEWriter::sendConfigurableDigitalOutput(uint8_t output_pin, bool value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTDEWriter::sendToolDigitalOutput(bool value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTDEWriter::sendStandardAnalogOuput(uint8_t output_pin, bool value)
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user