@@ -61,7 +61,6 @@ urcl::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_
6161 const uint32_t script_command_port, double force_mode_damping, double force_mode_gain_scaling)
6262 : servoj_gain_(servoj_gain)
6363 , servoj_lookahead_time_(servoj_lookahead_time)
64- , step_time_(std::chrono::milliseconds(8 ))
6564 , handle_program_state_(handle_program_state)
6665 , robot_ip_(robot_ip)
6766{
@@ -78,13 +77,8 @@ urcl::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_
7877 non_blocking_read_ = non_blocking_read;
7978 get_packet_timeout_ = non_blocking_read_ ? 0 : 100 ;
8079
81- if (!rtde_client_->init ())
82- {
83- throw UrException (" Initialization of RTDE client went wrong." );
84- }
85-
86- rtde_frequency_ = rtde_client_->getMaxFrequency ();
87- step_time_ = std::chrono::milliseconds (1000 / rtde_frequency_);
80+ initRTDE ();
81+ setupReverseInterface (reverse_port);
8882
8983 // Figure out the ip automatically if the user didn't provide it
9084 std::string local_ip = reverse_ip.empty () ? rtde_client_->getIP () : reverse_ip;
@@ -210,7 +204,6 @@ urcl::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_
210204 URCL_LOG_DEBUG (" Created script sender" );
211205 }
212206
213- reverse_interface_.reset (new control::ReverseInterface (reverse_port, handle_program_state, step_time_));
214207 trajectory_interface_.reset (new control::TrajectoryPointInterface (trajectory_port));
215208 script_command_interface_.reset (new control::ScriptCommandInterface (script_command_port));
216209
@@ -621,4 +614,35 @@ void UrDriver::setKeepaliveCount(const uint32_t count)
621614 reverse_interface_->setKeepaliveCount (count);
622615}
623616
617+ void UrDriver::resetRTDEClient (const std::vector<std::string>& output_recipe,
618+ const std::vector<std::string>& input_recipe, double target_frequency)
619+ {
620+ rtde_client_.reset (
621+ new rtde_interface::RTDEClient (robot_ip_, notifier_, output_recipe, input_recipe, target_frequency));
622+ initRTDE ();
623+ }
624+
625+ void UrDriver::resetRTDEClient (const std::string& output_recipe_filename, const std::string& input_recipe_filename,
626+ double target_frequency)
627+ {
628+ rtde_client_.reset (new rtde_interface::RTDEClient (robot_ip_, notifier_, output_recipe_filename, input_recipe_filename,
629+ target_frequency));
630+ initRTDE ();
631+ }
632+
633+ void UrDriver::initRTDE ()
634+ {
635+ if (!rtde_client_->init ())
636+ {
637+ throw UrException (" Initialization of RTDE client went wrong." );
638+ }
639+ }
640+
641+ void UrDriver::setupReverseInterface (const uint32_t reverse_port)
642+ {
643+ auto rtde_frequency = rtde_client_->getTargetFrequency ();
644+ auto step_time = std::chrono::milliseconds (static_cast <int >(1000 / rtde_frequency));
645+ reverse_interface_.reset (new control::ReverseInterface (reverse_port, handle_program_state_, step_time));
646+ }
647+
624648} // namespace urcl
0 commit comments