After much confusion, I made a table with legs that can move.
So I raised the table to z=1 plane and put the origin of the joints in the right place. THEN you set the legs/links with origin at -0.5 because the joint is at 1, and the leg is 1 long, and presumably it needs 0.5 because that’s the centre of the box.
I did visualisation by changing the filename in this file in the bullet3 folders, and running in python:
python3 biped2d_pybullet.py
seemed better than RViz
<?xml version="1.0"?>
<robot name="table">
<material name="white">
<color rgba="1 1 1 1"/>
</material>
<material name="black">
<color rgba="0.2 0.2 0.2 1"/>
</material>
<material name="blue">
<color rgba="0 0 1 1"/>
</material>
<link name="torso">
<visual>
<geometry>
<box size="2 2 0.1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 1"/>
<material name="white"/>
</visual>
<collision>
<geometry>
<box size="2 2 0.1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 1"/>
<contact_coefficients mu="0.08" />
</collision>
</link>
<link name="r_upperleg">
<visual>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<material name="black"/>
</visual>
<collision>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<contact_coefficients mu="0.08" />
</collision>
</link>
<joint name="torso_to_rightleg" type="revolute">
<parent link="torso"/>
<child link="r_upperleg"/>
<axis xyz="1 0 0"/>
<limit effort="0.0" lower="-1.57." upper="1.57" velocity="1000.0"/>
<origin rpy="0 0 0" xyz="1 1 1"/>
</joint>
<link name="l_upperleg">
<visual>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<material name="black"/>
</visual>
<collision>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<contact_coefficients mu="0.08" />
</collision>
</link>
<joint name="torso_to_leftleg" type="revolute">
<parent link="torso"/>
<child link="l_upperleg"/>
<axis xyz="1 0 0"/>
<limit effort="10.0" lower="-1.57." upper="1.57" velocity="1000.0"/>
<origin rpy="0 0 0" xyz="-1 1 1"/>
</joint>
<link name="front_r_upperleg">
<visual>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<material name="black"/>
</visual>
<collision>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<contact_coefficients mu="0.08" />
</collision>
</link>
<joint name="torso_to_frontrightleg" type="revolute">
<parent link="torso"/>
<child link="front_r_upperleg"/>
<axis xyz="1 0 0"/>
<limit effort="0.0" lower="-1.57." upper="1.57" velocity="1000.0"/>
<origin rpy="0 0 0" xyz="1 -1 1"/>
</joint>
<link name="front_l_upperleg">
<visual>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<material name="black"/>
</visual>
<collision>
<geometry>
<box size="0.1 0.1 1"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 -0.5"/>
<contact_coefficients mu="0.08" />
</collision>
</link>
<joint name="torso_to_frontleftleg" type="revolute">
<parent link="torso"/>
<child link="front_l_upperleg"/>
<axis xyz="1 0 0"/>
<limit effort="10.0" lower="-1.57." upper="1.57" velocity="1000.0"/>
<origin rpy="0 0 0" xyz="-1 -1 1"/>
</joint>
</robot>