@@ -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
@@ -593,4 +586,35 @@ void UrDriver::setKeepaliveCount(const uint32_t count)
593586 reverse_interface_->setKeepaliveCount (count);
594587}
595588
589+ void UrDriver::resetRTDEClient (const std::vector<std::string>& output_recipe,
590+ const std::vector<std::string>& input_recipe, double target_frequency)
591+ {
592+ rtde_client_.reset (
593+ new rtde_interface::RTDEClient (robot_ip_, notifier_, output_recipe, input_recipe, target_frequency));
594+ initRTDE ();
595+ }
596+
597+ void UrDriver::resetRTDEClient (const std::string& output_recipe_filename, const std::string& input_recipe_filename,
598+ double target_frequency)
599+ {
600+ rtde_client_.reset (new rtde_interface::RTDEClient (robot_ip_, notifier_, output_recipe_filename, input_recipe_filename,
601+ target_frequency));
602+ initRTDE ();
603+ }
604+
605+ void UrDriver::initRTDE ()
606+ {
607+ if (!rtde_client_->init ())
608+ {
609+ throw UrException (" Initialization of RTDE client went wrong." );
610+ }
611+ }
612+
613+ void UrDriver::setupReverseInterface (const uint32_t reverse_port)
614+ {
615+ auto rtde_frequency = rtde_client_->getTargetFrequency ();
616+ auto step_time = std::chrono::milliseconds (static_cast <int >(1000 / rtde_frequency));
617+ reverse_interface_.reset (new control::ReverseInterface (reverse_port, handle_program_state_, step_time));
618+ }
619+
596620} // namespace urcl
0 commit comments