This Project provides a simulation setup using PyBullet to load and control a robot model.
- Gravity and Physics Setup: Configures gravity in the simulation.
- Joint Control: Creates sliders for each robot joint to control their positions interactively.
- Collision Detection: Detects and logs collisions between the robot's links and other objects in the environment.
- The simulation runs at 240 Hz by default.
This code combines simulation, kinematics, and control to visualize the motion of a robot arm.

- roboticstoolbox: Used for modeling and controlling robots.
- swift: Provides a 3D visualization interface for robotics simulation.
- spatialmath: Handles transformations like rotations and translations.
- spatialgeometry: Adds geometric primitives for visualization.
- move_to_position: Moves the robot's end-effector to a target position using servoing. Computes joint velocities using the Jacobian and pseudoinverse.
Sequential movements along the x, y, and z axes demonstrate the robot’s capability.
Servoing is a feedback-based control technique that continuously adjusts the robot's motion to minimize the error between the current position (or pose) and the desired target position (or pose). The function rtb.p_servo is used for position-based servoing.
-
It calculates a velocity command v for the end-effector, based on the error between:
-
The current pose of the end-effector (from robot.fkine(robot.q)).
-
The target pose (Tep).
-
-
The gain parameter scales how aggressively the robot corrects the error.
-
The threshold parameter (set to 0.01) defines how close the end-effector must get to the target pose to consider the movement complete.
=> Servoing ensures that the end-effector dynamically adjusts its motion to precisely reach the target position.
Maps joint velocities (qd) to end-effector velocity (v):
v = J * qd
For non-square J, use the pseudoinverse (J⁺) to calculate qd:
qd = J⁺ * v
robot.jacobe(robot.q): ComputeJ.np.linalg.pinv(J): ComputeJ⁺.robot.qd = np.linalg.pinv(J) @ v: Calculateqdfor the desiredv.
Ensure the following libraries are installed in your Python environment:
roboticstoolbox
swift
numpy
spatialmath
spatialgeometry
1- Update the paths in the URDF file to match your local system. For example:
<mesh filename="/Users/OUSSAMA/Desktop/projects/WIP/Arm robot project/5- simulation/robotics_tool_box_python/arm_robot/arm_01.stl"/>
2- Update the path in python coode:
robot = rtb.Robot.URDF("/Users/OUSSAMA/Desktop/projects/WIP/Arm robot project/5- simulation/robotics_tool_box_python/arm_robot/robot.urdf")
The model is structured as a Rigid Body Tree, which is subsequently transformed into a Simscape model. The Simscape model allows control over the arm's actuation through motion and torque inputs.
- Control the motion and torque of the arm's joints.
- Low-Level Control: Adjust motion inputs directly using sliders.
- High-Level Control: Implement a PID controller to manage motion and torque inputs.
- Use the slider blocks in Simulink to adjust the motion of individual joints.
- Use the provided PID controller block to control both motion and torque.
- Adjust the PID parameters to optimize performance.



.png)
.png)




