Commit 0403bd33 authored by Daniella Tola's avatar Daniella Tola
Browse files

added scripts and guide for ursim

parent 6a43a113
import matplotlib.pyplot as plt
import third_party.rtde.csv_reader as csv_reader
from pathlib import Path
f_name = "test_motion1.csv"
filename = Path("robot_sim_tests") / Path("test_results") / Path(f_name)
print(f"filename: {filename}")
with open(filename) as csvfile:
rd = csv_reader.CSVReader(csvfile) # robot data object
t = rd.timestamp - rd.timestamp[0]
q_0 = rd.target_q_0
q_1 = rd.target_q_1
plt.plot(t, q_0, label='q_0')
plt.plot(t, q_1, label='q_1')
plt.xlabel('Time [s]')
plt.ylabel('Target Angular Position [rad]')
plt.legend()
plt.show()
\ No newline at end of file
<?xml version="1.0"?>
<rtde_config>
<recipe key="out">
<field name="timestamp" type="DOUBLE"/>
<field name="target_q" type="VECTOR6D"/>
<field name="target_qd" type="VECTOR6D"/>
<field name="target_qdd" type="VECTOR6D"/>
<field name="target_current" type="VECTOR6D"/>
<field name="target_moment" type="VECTOR6D"/>
<field name="actual_q" type="VECTOR6D"/>
<field name="actual_qd" type="VECTOR6D"/>
<field name="actual_current" type="VECTOR6D"/>
<field name="joint_control_output" type="VECTOR6D"/>
<field name="actual_TCP_pose" type="VECTOR6D"/>
<field name="actual_TCP_speed" type="VECTOR6D"/>
<field name="actual_TCP_force" type="VECTOR6D"/>
<field name="target_TCP_pose" type="VECTOR6D"/>
<field name="target_TCP_speed" type="VECTOR6D"/>
<field name="actual_digital_input_bits" type="UINT64"/>
<field name="joint_temperatures" type="VECTOR6D"/>
<field name="actual_execution_time" type="DOUBLE"/>
<field name="robot_mode" type="INT32"/>
<field name="joint_mode" type="VECTOR6INT32"/>
<field name="safety_mode" type="INT32"/>
<field name="actual_tool_accelerometer" type="VECTOR3D"/>
<field name="speed_scaling" type="DOUBLE"/>
<field name="target_speed_fraction" type="DOUBLE"/>
<field name="actual_momentum" type="DOUBLE"/>
<field name="actual_main_voltage" type="DOUBLE"/>
<field name="actual_robot_voltage" type="DOUBLE"/>
<field name="actual_robot_current" type="DOUBLE"/>
<field name="actual_joint_voltage" type="VECTOR6D"/>
<field name="actual_digital_output_bits" type="UINT64"/>
<field name="runtime_state" type="UINT32"/>
<!--
<field name="script_control_line" type="UINT32"/>
<field name="output_bit_registers0_to_31" type="UINT32"/>
<field name="output_bit_registers32_to_63" type="UINT32"/>
<field name="output_int_register_0" type="INT32"/>
<field name="output_int_register_1" type="INT32"/>
<field name="output_int_register_2" type="INT32"/>
<field name="output_int_register_3" type="INT32"/>
<field name="output_int_register_4" type="INT32"/>
<field name="output_int_register_5" type="INT32"/>
<field name="output_int_register_6" type="INT32"/>
<field name="output_int_register_7" type="INT32"/>
<field name="output_int_register_8" type="INT32"/>
<field name="output_int_register_9" type="INT32"/>
<field name="output_int_register_10" type="INT32"/>
<field name="output_int_register_11" type="INT32"/>
<field name="output_int_register_12" type="INT32"/>
<field name="output_int_register_13" type="INT32"/>
<field name="output_int_register_14" type="INT32"/>
<field name="output_int_register_15" type="INT32"/>
<field name="output_int_register_16" type="INT32"/>
<field name="output_int_register_17" type="INT32"/>
<field name="output_int_register_18" type="INT32"/>
<field name="output_int_register_19" type="INT32"/>
<field name="output_int_register_20" type="INT32"/>
<field name="output_int_register_21" type="INT32"/>
<field name="output_int_register_22" type="INT32"/>
<field name="output_int_register_23" type="INT32"/>
<field name="output_double_register_0" type="DOUBLE"/>
<field name="output_double_register_1" type="DOUBLE"/>
<field name="output_double_register_2" type="DOUBLE"/>
<field name="output_double_register_3" type="DOUBLE"/>
<field name="output_double_register_4" type="DOUBLE"/>
<field name="output_double_register_5" type="DOUBLE"/>
<field name="output_double_register_6" type="DOUBLE"/>
<field name="output_double_register_7" type="DOUBLE"/>
<field name="output_double_register_8" type="DOUBLE"/>
<field name="output_double_register_9" type="DOUBLE"/>
<field name="output_double_register_10" type="DOUBLE"/>
<field name="output_double_register_11" type="DOUBLE"/>
<field name="output_double_register_12" type="DOUBLE"/>
<field name="output_double_register_13" type="DOUBLE"/>
<field name="output_double_register_14" type="DOUBLE"/>
<field name="output_double_register_15" type="DOUBLE"/>
<field name="output_double_register_16" type="DOUBLE"/>
<field name="output_double_register_17" type="DOUBLE"/>
<field name="output_double_register_18" type="DOUBLE"/>
<field name="output_double_register_19" type="DOUBLE"/>
<field name="output_double_register_20" type="DOUBLE"/>
<field name="output_double_register_21" type="DOUBLE"/>
<field name="output_double_register_22" type="DOUBLE"/>
<field name="output_double_register_23" type="DOUBLE"/>
-->
</recipe>
</rtde_config>
from urinterface.robot_connection import RobotConnection
import numpy as np
from pathlib import Path
q0 = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) # configuration no. 1
q1 = np.array([1.3, 0.0, 0.0, 0.0, 0.0, 0.0]) # configuration no. 2
v0 = 2.0
a0 = 8.0
vm_ip = "192.168.80.128"
ur5e = RobotConnection(vm_ip) # Establish dashboard connection (port 29999) and controller connection (port 30002)
# Now, move to joint angular position q = q0 with joint angular velocity v = v0 and joint angular acceleration a = a0
ur5e.movej(q=q0, v=v0, a=a0)
# Create filename
f_name = "test_motion1.csv"
filename = Path("robot_sim_tests") / Path("test_results") / Path(f_name)
# Specify config file path
config_file = Path("robot_sim_tests") / Path("resources") / Path("record_configuration.xml")
ur5e.start_recording(filename=filename, overwrite=True, config_file=config_file) # start recording and place the recorded data in test_motion.csv
ur5e.movej(q=q1, v=v0, a=a0) # move to joint angular position q = q1
ur5e.stop_recording()
\ No newline at end of file
# Download URsim
The link is for non-linux platforms, but can be changed for linux platforms if required.
https://www.universal-robots.com/download/?option=77063#section41570
# Setup VM network adapter
Follow the last section of the link (Part 8: Set Up of Network Adapter)
https://academy.universal-robots.com/media/jiehhszc/ursim_vmoracle_installation_guidev03_en.pdf
If you cannot ping from the VM to the host machine, then try checking out the following link:
https://superuser.com/questions/1214547/unable-to-ping-from-vms-to-host-machine
# Setup urinterface
Follow the instructions in the link:
https://pypi.org/project/urinterface/
# Run urinterface
Run the file _run_experiment.py_ in the folder _robot_sim_tests_ and remember to specify the correct IP address of the virtual machine.
## Check if everything is working correctly
### 1 Confirm the robot runs when you run the experiment
You can confirm if the robot starts running, when you run the python experiment by looking at the bottom left corner of the simulator. The figure below shows how the simulator looks when it is running.
<img src="../assets/sim_running.png"
alt="The robot is currently being simulated and is running"/>
### 2 Change the specified IP address of the VM
You can also change the specified IP address of the VM and it should give an error, explaining it cannot make a connection.
\ No newline at end of file
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment