In order to be able to control the pupper, the first thing we would need is to get the position of the legs. What we are given through the power of ROS magic as an input is the angles of each joint, and by knowing the topology of the robot we can figure out the end position of each leg through the power of linear algebra.
Recall from computer graphics that points in space are represented with vectors, and that any transformations can be represented with a matrix
cd ~/lab_2_fall_2025 code .
tar -xvf pupper_viz.tar.gz cd pupper_viz/ docker build -t pupper_viz .
Once done, you may paste your forward_kinematics solution into the lab_2.py and then
./run.sh
Before we start implementing the TODOs, let's understand the structure of the lab_2.py file:
ForwardKinematics class that inherits from rclpy.node.Nodejoint_states topic and publishes to the leg_front_1_end_effector_position and marker topics.forward_kinematics method is where we'll implement the forward kinematics calculationslab_2.py and locate the forward_kinematics method.
T_0_1. This involves a translation and two rotations. We include a visualization of this transformation below to facilitate your understanding (keeping all these in mind can be tricky!). Understanding this transformation will help you complete the remainder of the transformations.lab_2.pyros2 launch lab_2.launch.py
python lab_2.py
To test your code in simulation to make sure that the code works as expected, you can use RVIZ2. RVIZ2 will show the Pupper model as well as a marker that shows the output from the forward kinematics.
rviz2 -d lab_2.rviz
The above command will load the RVIZ config file. If you just run rviz2, you can manually add the configuration. After running rviz, click the “Add” button, and then select a Robot Model type. Select the /robot_description topic. Next, add the marker by selecting “Add” again, and select a Marker type. Select the topic /marker.
If you finish early and want to explore further:
We provide the base link to leg_back_r1 transformation in the diagram below. The rest of the transformations are identical to the front leg: